Tree Scene Node v2.1

Announce new projects or updates of Irrlicht Engine related tools, games, and applications.
Also check the Wiki
lug
Posts: 79
Joined: Tue May 02, 2006 5:15 am
Contact:

Post by lug »

Klasker wrote:Re-animating an old thread.

It is about time updated the source to be compatible with Irrlicht 1.1. Download the new source (808 KB).
Irrlicht.dll and the .exe file are no longer included in the download.

There are no new features though.. :( I will improve it later.
Hmmm...It can't seem to find "CNewTreeProfile.h."

Update:

Man, Klasker, your code has beaten me into submission! But I shall continue to try to compile/build it against the SVN version. :?
Klasker
Posts: 230
Joined: Thu May 20, 2004 8:53 am
Contact:

Post by Klasker »

Oops.. just some stray changes in main.cpp. Updated the download.
The tree code itself shouldn't be broken. The CNewTreeProfile was an experiment I worked on, but it seems I forgot to remove it from main.cpp before uploading :(
Man, Klasker, your code has beaten me into submission!
I have no idea that means.
lug
Posts: 79
Joined: Tue May 02, 2006 5:15 am
Contact:

Post by lug »

Man, Klasker, your code has beaten me into submission!
I have no idea that means.[/quote]

Well, I can't seem to locate where you define "MeshBuffer" in any of the files in the zip archive. :(
Aranoth
Posts: 4
Joined: Sun Nov 12, 2006 11:53 am
Location: France
Contact:

Post by Aranoth »

Great !

But it doesn't work with the SVN version, I found where it crash :

Code: Select all

BranchesLOD.clear();
for( s32 i=0; i<treeProfile->getMaxLOD()+1; i++ )
{
    [b]BranchesLOD.push_back( core::list< SBranch* >() );[/b]
}
Klasker
Posts: 230
Joined: Thu May 20, 2004 8:53 am
Contact:

Post by Klasker »

I wonder when array and list will start working properly together :?
When upgrading from v1.0 to v1.1 I had to change that part of the code to prevent crashes. Now it seems I have to change it again :(

Technically (I think) the code is legal, but it is due to a bug with the array<list> type. I don't use SVN so I won't fix this until v1.2.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Which bug?
Klasker
Posts: 230
Joined: Thu May 20, 2004 8:53 am
Contact:

Post by Klasker »

I don't have SVN so I can't tell exactly, but if the code does indeed crash where Aranoth suggests something would imply that core::array<T> does not work well with T=core::list<S> where S=a pointer type.
I don't know whether it is a bug or just a improper use the template core::array<T>, but it worked in version 1.1 - so something must have changed in SVN that makes it not work anymore.
hellbound
Posts: 51
Joined: Sat Jun 24, 2006 7:39 am

Post by hellbound »

klasker... you really did a great job here , with this... but you could try adding more types of trees and eventually an export function... ;)
n00b
Posts: 58
Joined: Tue Sep 05, 2006 3:00 pm
Location: Earth
Contact:

Post by n00b »

hi,
i'm having a problem with creating multiple trees using this node.
if i create more than one tree, one tree has leaves but the rest doesn't! Why?

also, i set the material type of the leaves so that they are not see through (alpha channel not used) and i can see that the leaves are all messed up. they are stretched to the floor.

can anyone help?
Klasker
Posts: 230
Joined: Thu May 20, 2004 8:53 am
Contact:

Post by Klasker »

How are you creating the leaves? Try posting some code...
n00b
Posts: 58
Joined: Tue Sep 05, 2006 3:00 pm
Location: Earth
Contact:

Post by n00b »

heres the function i use for creating trees:

Code: Select all

//! The AddTree() function to add trees to scenes
void CGamePlayState::AddTree(CGameManager* pManager, E_TREE_PROFILE treeProfile,
    ITexture* TLeafTex, ITexture* TTreeTex, s32 Tseed, s32 Tlod, f32 trunkRadius,
    f32 treeSize, vector3df pos)
{
    STree* tree = new STree;
    // TREES
    // MAIN
    tree->generator = new CTreeGenerator();
     if (treeProfile == ETP_STANDARD)
    {
        tree->profile = tree->stdProfile  =  new CStandardTreeProfile();
        tree->stdProfile->setMaxLOD( Tlod );
        tree->stdProfile->setTrunkRadius( trunkRadius );
        tree->stdProfile->setTreeSize( treeSize );
    }
    else if (treeProfile == ETP_PINE)
    {
        tree->profile = tree->pineProfile = new CPineTreeProfile();
        tree->pineProfile->setMaxLOD( Tlod );
        tree->pineProfile->setTrunkRadius( trunkRadius );
        tree->pineProfile->setTreeSize( treeSize );
    }
    tree->seed = Tseed;
    tree->lod = Tlod;
    tree->leafTex = TLeafTex;

    tree->treeNode = new CLODMeshSceneNode( pManager->getSceneManager()->getRootSceneNode(),
        pManager->getSceneManager());
    tree->treeNode->setMaterialFlag( EMF_LIGHTING, false );
    tree->treeNode->setMaterialTexture( 0, TTreeTex);
    tree->treeNode->drop();

    tree->wind = createWindGenerator();

    tree->leafNode = new CTreeLeafSceneNode( pManager->getSceneManager()->getRootSceneNode(),
        pManager->getSceneManager() );
    tree->leafNode->setWindGenerator( tree->wind );
    tree->leafNode->setMaterialFlag( EMF_LIGHTING, false );
    tree->leafNode->setMaterialType( EMT_TRANSPARENT_ALPHA_CHANNEL );
    tree->leafNode->setMaterialTexture( 0, tree->leafTex );
    tree->leafNode->drop();

    tree->wind->drop();

    // generateTree()-------------
    ILODMesh* treeMesh = tree->generator->generateTree(
        tree->profile, tree->seed, 10 );
    ILODMesh* leafMesh = tree->generator->generateLeaves();

    tree->treeNode->setMesh( treeMesh );
    tree->leafNode->setMesh( leafMesh );

    treeMesh->drop();
    leafMesh->drop();

    tree->treeNode->setCurrentLOD( tree->lod );
    tree->leafNode->setCurrentLOD( tree->lod );
    //----------------------------

    tree->treeNode->setPosition( pos );
    tree->leafNode->setPosition( tree->treeNode->getPosition() );

    delete tree;
}
And I create the tree like this:

Code: Select all

// add tree
    ITexture* LT = pManager->getDriver()->getTexture("media/leaf.tga");
    ITexture* TT = pManager->getDriver()->getTexture("media/tree.jpg");
    AddTree(pManager, ETP_STANDARD, LT, TT,
        20, 5, 40, 200, vector3df(1000,930,2150));
    AddTree(pManager, ETP_STANDARD, LT, TT,
        50, 5, 50, 200, vector3df(1000,930,2150));
The first tree is fine, the second doesn.t have any leaves.
jAyTeA
Posts: 36
Joined: Wed Sep 06, 2006 7:50 am
Location: Hattorf am Harz, Germany

Post by jAyTeA »

Hi,

this thing sounds great, when i trie to run this with irrlich 1.2 im getting the same error as Aranoth.
Can you fix that please? I have no idea, how to solve that.

In advance:
Thanks!
Klasker
Posts: 230
Joined: Thu May 20, 2004 8:53 am
Contact:

Post by Klasker »

I have uploaded a new version that works in Irrlicht v. 1.2, but no new features have been added. I'm trying to figure out an easier way to make new tree profiles, seeing as it is a pretty dreadful task at the moment.

Download it here (2 MB).
hellbound wrote:klasker... you really did a great job here , with this... but you could try adding more types of trees and eventually an export function... ;)
The whole point of procedural trees is that you don't to load them from files. You only need to store the seed number and which profile you used to get the same tree back. If you want to export to a mesh format such as .3ds, any 3ds-exporter that supports Irrlicht's IMesh class should work, since ILODMesh inherits from IMesh.
And as I mentioned above, I'm working on a better way to add more profiles.
n00b wrote:heres the function i use for creating trees: (...)
I can't see anything wrong in your code, but try the new version and see if it fixes the problem.
raven_coda
Posts: 89
Joined: Thu Aug 17, 2006 8:11 pm
Location: Salt Lake City, UT, USA
Contact:

Post by raven_coda »

Yeah.....


Maybe I'm missing something simple but just trying to complie your code and having trouble.

I'm getting a handful of errors from SLODMesh.cpp

Just looking through them...
Error 1 error C2511: 'irr::scene::IMeshBuffer &irr::scene::SLODMesh::getMeshBuffer(void)' : overloaded member function not found in 'irr::scene::SLODMesh'
Error 2 error C2084: function 'irr::core::aabbox3d<T> &irr::scene::SLODMesh::getBoundingBox(void)' already has a body
Error 3 error C2065: 'MeshBuffer' : undeclared identifier
Could it be possible you zipped the wrong version of a file?
SLODMesh.cpp modified date -> 5/15/2006
SLODMesh.h modified dat -> 11/30/2006

the two don't seem to line up on function declerations

Is this correct? If so then can you tell me what I might be doing wrong?
Definition of an Upgrade: Take old bugs out, put new ones in.
Klasker
Posts: 230
Joined: Thu May 20, 2004 8:53 am
Contact:

Post by Klasker »

*Sigh* Why does this happen to me all the time :(

Anyway, just remove the file: SMeshBuffer.cpp
Remove it from the project. Delete it. You don't need it. I removed it from the Dev-C++ example project, but forgot to delete the file from the folder.
Post Reply