POV-Ray : Newsgroups : povray.general : Instancing Trees : Re: Instancing Trees Server Time
30 Jul 2024 16:25:03 EDT (-0400)
  Re: Instancing Trees  
From: Mike Williams
Date: 16 Oct 2008 01:35:29
Message: <HFHO2AB9It9IFwiH@econym.demon.co.uk>
Wasn't it slongay who wrote:
>Hi, I am trying to build a scene with many trees though many of the 
>trees can be
>the same just rotated or scaled slightly. My current setup is as follows
>
>#declare leaf1 = mesh { smooth_triangle ... }
>#declare leaf2 = mesh { smooth_triangle ... }
>
>#declare tree = object { union {
>mesh { triangles for a branch }
>mesh { triangles for another branch}
>.... // for all branches
>object { object { object { leaf1 scale<x,y,z> } matrix ...} translate<x,y,z> }
>object { object { object { leaf2 scale<x,y,z> } matrix ...} translate<x,y,z> }
>.... // continues for all leaves
>}
>translate<x,y,z> // to place the base of the model at <0,0,0>
>scale<x,y,z> // to adjust the size of the model
>}
>
>
>Then in my program I instance this tree object many times with
>
>object { tree scale<x,y,z> rotate<x,y,z> translate<x,y,z> }
>
>But this causes POV-ray to run out of memory very quickly so I don't think this
>is instancing the geometry properly.
>
>From reading the manual it says that mesh's can be instanced but is it 
>because I
>have a bunch of mesh's in a union that this does not work?
>
>Is the only solution to this to make one massive mesh which has all branch
>geometry and all leaf geometry inside it and then instance that?

Paul T. Dawson released the wonderful meshtree.inc back in 1999, which 
creates a tree as one large mesh. It was fast and memory efficient on 
1999 hardware. On modern computers it's blindingly fast. There's a demo 
scene that comes with it that plots 999 copies of a moderately detailed 
tree. On my machine it takes 4 seconds to parse and uses a peak memory 
of 9.7 Mb. It might be worth taking a look at how he did that.

It may well be possible to do it slightly more simply now that POVRay 
has mesh2.

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.