Tree Scene Node v2.1

Announce new projects or updates of Irrlicht Engine related tools, games, and applications.
Also check the Wiki
overburn
Posts: 101
Joined: Sun Nov 04, 2007 8:08 am
Location: Romania, Ploiesti

Post by overburn »

ok...
erm.. excuse a n00b question...
but how do i use this to generate trees into my application?
One Tequila, Two Tequila, Three Tequila, Floor.
_______________________________________
ASUS P5V-VM Ultra
Intel Pentium D930
1x 2GB DDR2 Kingmax 800mhz/533mhz mb
Leadtek PX9600GT W 512MB DDR3
200GB Maxtor HDD
Klasker
Posts: 230
Joined: Thu May 20, 2004 8:53 am
Contact:

Post by Klasker »

You need to add all the .h and .cpp files except main.cpp to your project. See main.cpp for an example of how to generate and display trees. Basically, you use the CTreeGenerator to create an STreeMesh instance, and then send that to a CTreeSceneNode.
christianclavet
Posts: 1638
Joined: Mon Apr 30, 2007 3:24 am
Location: Montreal, CANADA
Contact:

Post by christianclavet »

Hi. Do you think it's possible to create a PALM tree design?
Klasker
Posts: 230
Joined: Thu May 20, 2004 8:53 am
Contact:

Post by Klasker »

I'm afraid palm trees are somewhat difficult to add at the moment because of the way leaves are handled.

On another subject, I am playing with the idea of using L-systems to generate the trees, similar to the way SpeedTree does it, which is a more organic approach instead of my current recursive approach. It is still just a thought, so don't get excited yet.
shogun
Posts: 162
Joined: Wed Sep 05, 2007 11:02 am
Location: inside

Post by shogun »

Hi,

I created an irrEdit plugin out of your Tree Scene Node (sorry, if this has been done before - I couldn't find it). Download.

In IrrEdit 0.7.1:

Image

In Irrlicht 1.4beta:

Image

As you can see, the trees look different, in spite of being the same one, with the same seed. I probably will investigate this.

----

Update: The plugin now works with irrEdit 1.4alpha. The seeds are now correct when importing the trees into irrlicht.
Last edited by shogun on Thu Nov 29, 2007 9:25 am, edited 2 times in total.
Virion
Competition winner
Posts: 2148
Joined: Mon Dec 18, 2006 5:04 am

Post by Virion »

It's very nice so far.
Klasker
Posts: 230
Joined: Thu May 20, 2004 8:53 am
Contact:

Post by Klasker »

I created an irrEdit plugin out of your Tree Scene Node (sorry, if this has been done before - I couldn't find it).
(...)
As you can see, the trees look different, in spite of being the same one, with the same seed. I probably will investigate this.
Looks cool. I haven't used irrEdit myself, but I can imagine it is quite useful. Would you mind if I link to the plugin in the first post? I will mention it is made by you, of course. I hope you can fix the seed issue, though I doubt I can be of much help there.
shogun
Posts: 162
Joined: Wed Sep 05, 2007 11:02 am
Location: inside

Post by shogun »

Go ahead, I'm the last one who would mind. ;)

BTW, in order to get the thing to work, I had to make BillboardMaterial and the TreeMaterial of CTreeSceneNode protected (instead of private).
Klasker
Posts: 230
Joined: Thu May 20, 2004 8:53 am
Contact:

Post by Klasker »

Updated for Irrlicht 1.4. Download.
christianclavet
Posts: 1638
Joined: Mon Apr 30, 2007 3:24 am
Location: Montreal, CANADA
Contact:

Post by christianclavet »

Thanks Klasker.
etcaptor
Posts: 871
Joined: Fri Apr 09, 2004 10:32 pm
Location: Valhalla
Contact:

Post by etcaptor »

1.3 and 1.4 examples crashes for me at beginning. Any ideas what? Maybe you files are compiled with another DirectX version? I use DX 9c.
ImageImage
Site development -Rock and metal online
--- etcaptor.com ------freenetlife.com
Klasker
Posts: 230
Joined: Thu May 20, 2004 8:53 am
Contact:

Post by Klasker »

The example uses OpenGL and it uses a GLSL shaders to draw the leaves, so it's not a D3D-issue. Did you run the precompiled file I provided (in the msvc folder) or did you compile it yourself?

In any case, it looks for its data files in e.g. "../textures", and it sounds like it can't find one of the files it is using.
etcaptor
Posts: 871
Joined: Fri Apr 09, 2004 10:32 pm
Location: Valhalla
Contact:

Post by etcaptor »

Thanks fo reply Klasker
Yes, I use your precompiled file in msvc folder only. It's crashes on my home and job PC /XP geForce 6600 and geForce 8600/. Only 1.2 version runs well.
ImageImage
Site development -Rock and metal online
--- etcaptor.com ------freenetlife.com
etcaptor
Posts: 871
Joined: Fri Apr 09, 2004 10:32 pm
Location: Valhalla
Contact:

Post by etcaptor »

Because precompiled example crashes on my home an office PC, I made some debugging after quick look on you code. Here will post what I found:

In your main function these lines are involved:

Code: Select all

tree = new CTreeSceneNode( manager->getRootSceneNode(), manager );
tree->getLeafNode()->applyVertexShadows( lightDir, 1.0f, 0.25f );
generateNewTree();
generateNewTree(); function performs tree->setup(......) method;
But executing of CTreeSceneNode::setup(...) method races with another methods that invoke empty HighLODMeshBuffer pointer initialized by setup(....) method. That is the problem - which method is faster on different PC.
So, here is a little bypass from this situation:

In CTreeSceneNode::OnRegisterSceneNode() You can add checking for HighLODMeshBuffer

Code: Select all

            if(HighLODMeshBuffer)   
            {
                core::vector3df center = HighLODMeshBuffer->BoundingBox.getCenter();
                AbsoluteTransformation.rotateVect(center);

                center += getAbsolutePosition();

                DistSQ = (campos - center).getLengthSQ();
            }
Now avoid from accessing of BoundingBox through empty pointer:

Code: Select all

const core::aabbox3d<f32>& CTreeSceneNode::getBoundingBox() const
{
     if(HighLODMeshBuffer) 
     {
        BBox.reset(HighLODMeshBuffer->BoundingBox);
     }

     return BBox; //added class member
}
In main() function:

Code: Select all

     if(tree->getLeafNode()) //recommended
        tree->getLeafNode()->applyVertexShadows( lightDir, 1.0f, 0.25f );
ImageImage
Site development -Rock and metal online
--- etcaptor.com ------freenetlife.com
Klasker
Posts: 230
Joined: Thu May 20, 2004 8:53 am
Contact:

Post by Klasker »

Could you please point out how a race condition can occur in a single-threaded application? I didn't think so. It is not a race condition.

It sounds like it can't load the XML files in the "../trees" folder, which explains why the tree mesh is null. Did you export all the files from the .zip? Are you running the file directly, or using a shortcut with a modified "Start in"-folder?

Maybe it's a rights issue. Does the program has the privileges to read from the "../trees" folder?
Post Reply