Need help?

Coordinator
Nov 6, 2007 at 5:20 PM
Edited Jan 29, 2009 at 5:06 PM
If you need help using XNA Procedural LTrees in your project, please post a discussion and I will do my best to help you out. I should automatically receive an email when something happens here, so I will normally be able to respond within one day.
Feb 6, 2009 at 7:24 PM
Edited Feb 6, 2009 at 7:24 PM
Hi Asger,

I'm trying to implement your LTrees in my project, and for some reason whenever I draw them in my gameworld, it messes up the drawing of some of my other models, namely the terrain, from what I can tell.

Here's how it should look:



And here it is with the tree being drawn, just one tree:


Any idea how I can fix this? I'd really love to be able to use this library in my game! Regards, dj357
Coordinator
Feb 6, 2009 at 7:30 PM
The trunk and leaves do not restore the previous render states after drawing. Try putting a StateBlock.Capture() and StateBlock.Apply() around it to see if it helps. If that works, you can set the specific render states manually instead of using StateBlock, to gain some efficiency.
Feb 6, 2009 at 7:55 PM
Hmm...i'm not sure how to use the StateBlock correctly, but I did add this line of code at the end of all the draw methods I could find in the library:

device.RenderState.DepthBufferEnable = true;
device.RenderState.AlphaBlendEnable = false;
device.RenderState.AlphaTestEnable = false;
device.SamplerStates[0].AddressU = TextureAddressMode.Wrap;
device.SamplerStates[0].AddressV = TextureAddressMode.Wrap;

I use this line after SpriteBatch calls to restore the RenderStates necessary for 3D model drawing, but it didn't appear to have any affect.

How would I use the StateBlock?
Coordinator
Feb 8, 2009 at 9:21 AM
Sorry for the late response. Just create a StateBlock in the LoadContent method. When calling Capture() it will remember the current render states, and when calling Apply() it will restore the render states it stored. So just call Capture() before drawing trees, and Apply() afterwards to see if it is a render state issue, which I am pretty sure it is.
Feb 8, 2009 at 4:40 PM
Hi,

is it possible to use this library in Xbox360 project ? Win version of project is OK, Xbox gives me some errors, like:

Error 3 Building content threw FileNotFoundException: Could not load file or assembly 'Microsoft.Xna.Framework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=51c3bfb2db46012c' or one of its dependencies. The system cannot find the file specified.
   at LTreesLibrary.Pipeline.TreeProfileProcessor.Process(XmlDocument input, ContentProcessorContext context)
   at Microsoft.Xna.Framework.Content.Pipeline.ContentProcessor`2.Microsoft.Xna.Framework.Content.Pipeline.IContentProcessor.Process(Object input, ContentProcessorContext context)
   at Microsoft.Xna.Framework.Content.Pipeline.BuildCoordinator.BuildAssetWorker(BuildItem item)
   at Microsoft.Xna.Framework.Content.Pipeline.BuildCoordinator.BuildAsset(BuildItem item)
   at Microsoft.Xna.Framework.Content.Pipeline.BuildCoordinator.RunTheBuild()
   at Microsoft.Xna.Framework.Content.Pipeline.Tasks.BuildContent.RemoteProxy.RunTheBuild(BuildCoordinatorSettings settings, TimestampCache timestampCache, ITaskItem[] sourceAssets, String[]& outputContent, String[]& rebuiltContent, String[]& intermediates, Dictionary`2& dependencyTimestamps, KeyValuePair`2[]& warnings) C:\Users\BadKarma\Documents\Visual Studio 2008\Projects\MoonGate\MoonGate\Content\trees\Birch.ltree MoonGate 360



Feb 8, 2009 at 4:47 PM
Thanks Asger, that fixed the problem. Thanks!
Coordinator
Feb 8, 2009 at 5:12 PM
@BadKarma: I have no experience with XBox360 projects as I do not own a box myself. But as the error suggests, it looks like the .ltree files did not make it to your XBox360 project. The pipeline extensions do not load files in any untraditional ways.
Feb 8, 2009 at 5:41 PM
@Asger 
Hm, that is really strange, Importer and Processor for these files are recognized and set like in Win version, and Win v. of project does not have any problems with finding these files (same structure as you recommend in your todo list ).

BTW in XmlUtil.cs I had to leave out everywhere in byte.Parse second argument - Compact FW does not have this version of method with your 2nd param.

byte r = byte.Parse(parts[0]);
Apr 18, 2009 at 11:28 PM
Yes you are right, you can try changing in XmlUtils.cs declaration of numberFormat with :

private

 

static readonly NumberStyles numberFormat = NumberStyles.Number;

But, running on X360 it gives and OutOfMemory generating the TreeMesh event with  maxRadialSegments setted to 4.

Is there a way to reduce number of triangles in trunk mesh ?

 

Coordinator
Apr 19, 2009 at 7:56 AM
elettrozero the change you made to XmlUtils is a serious mistake and should be changed back. Do like BadKarma, by changing the parameter to byte.Parse works. I can explain shortly why it went so wrong:

Some countries use comma as decimal separator, and dot as thousands separator as opposed to the US where dot is the decimal separator and comma is the thousands separator. The method float.Parse(String) uses the machine's local settings. This means that the number "2.000" can either be parsed as two thousand, or just two. When reading from a file, this is just terrible. Using the invariant IFormatProvider, the US convention is forced, so it works the same everywhere. The change you made resulted in a number like "0.3" to be parsed as "3.0" on your system, which I presume lead to an enormously large tree. I tested the same thing on Windows, and I also get OutOfMemory error, so it is not specific to XBox360.
Apr 19, 2009 at 9:26 AM
Luckly I was wrong, so I can see trees on my X360.
But...for conversion probles ? Buildong the solution for X360 does no recognize the float.Parse overload with NumberFormatInfo...there's no NumberStyles variant to use with ?

Thanks so far.
Coordinator
Apr 19, 2009 at 9:42 AM
Just replace "byte.Parse(parts[x], numberFormat)" with "byte.Parse(parts[x], NumberStyles.Number, numberFormat)" where x is either 0,1,2, or 3, and it should work on your XBox360.
Apr 18, 2010 at 7:29 PM

Hi,

I've read in the documentation that you could make a lowpoly model of the tree. But I don't get how to implent it, I use SimpleTree.

Coordinator
Apr 20, 2010 at 6:14 PM

Hello Mattan360,

You cannot use SimpleTree to create a low-poly version of a tree. You need to use Effect, TreeMesh and TreeLeafCloud manually to render your trees. Looking in the source code for SimpleTree is probably your best reference. To have both a highpoly and a lowpoly version of a tree, you need two TreeMesh instances.

Apr 20, 2010 at 6:45 PM

Ok, thank you.

Nov 25, 2010 at 7:03 PM

Hello,

 

Recently I tried to convert this engine to XNA 4.0, everything went greate despite one thing, when leaves are drawn, blending not works, all leaves have black background, and I really have no Idea what to do with that.

Maybe someone succesfully converted this to xna 4.0?