Re: [osg-users] extend osgforest with a tree position raster mask

2009-02-28 Thread Robert Osfield
HI Christian,

The way to use a mask like this would be to read an osg::Image and
read from it directly.  There is no reason to require the use
Texture2D - this is only required if you want to do operations down on
the GPU.  osg::Image does have access methods for getting individual
pixels.

However, the way I'd tackle this problem would be by providing
boundary polygons which are then tessellated to provide a triangular
mesh that acts to describe the forest coverage.  One would then
compute the area for each of these triangles and then have a map of
accumulated area to index position into the triangle list.  This would
give us the ability to have a random value map to a particular
triangle, one then can use two more random values to provide the
baricentric coords within than triangle and form this to the final XY
location.   From the XY location you then intersect the terrain and
place the tree.

A variation on this would be use the a subset of the actual terrain
mesh, as this would then avoid the need for doing the intersection
test as you'd get the correct XYZ location. The boundaries of the
terrain triangles would might also be something that you'd want to
manage to avoid an artificial look, this could be done by trimming a
copy of the terrain triangles of interest by the polygonal boundary.

A further variation on this would be to add probability weights to the
vertices of the coverage mesh so you can change the density of trees
across the model, one also could through in tree type variation at the
same time.

All of this is well outside the scope of the osgforest example though,
but hopefully should give you a few ideas.

Robert.

On Sat, Feb 28, 2009 at 12:24 AM, Christian Sam osgfo...@tevs.eu wrote:
 hi,

 i would like to extend the example-program osgforest in a way so that the 
 placement of trees becomes user-controllable via an additional raster mask. 
 in detail: a 1bit rasterfile should mark treeless areas with a value of 0 
 and tree-covered areas with a value of 1. subsequent this mandatory 
 partitioning, i would like use the existing, random placement of trees in 
 tree-covered areas.

 i'm new to osg, so i have a few questions about how to implement this, and 
 would also be happy to get some clues from you.


 * can i use a simple osg::texture2D (nearest neighbour worldcoordinate scaled 
 to osgforest's terrain extent), as raster mask?

 * if yes, how can i query/access a raster value at a specific texture 
 coordinate?

 * how can i prevent that the raster mask will be rendered in the final scene? 
 (would a nodemask be the right way, or are there any better/simpler ways?)

 * in this first approach i will only implement 2 different tree regions: 
 covered and non-covered. my plan is to extend to the existing 
 createTreeList function with a simple check for the raster mask value at 
 the randomly generated tree position coordinates. only if it happens to lie 
 inside a tree-covered area, the tree will be pushed into the trees list. 
 maybe someone knows a more elegant way?


 best regards,
 christian

 --
 Read this topic online here:
 http://forum.openscenegraph.org/viewtopic.php?p=7664#7664





 ___
 osg-users mailing list
 osg-users@lists.openscenegraph.org
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] extend osgforest with a tree position raster mask

2009-02-27 Thread Christian Sam
hi,

i would like to extend the example-program osgforest in a way so that the 
placement of trees becomes user-controllable via an additional raster mask. in 
detail: a 1bit rasterfile should mark treeless areas with a value of 0 and 
tree-covered areas with a value of 1. subsequent this mandatory partitioning, 
i would like use the existing, random placement of trees in tree-covered areas.

i'm new to osg, so i have a few questions about how to implement this, and 
would also be happy to get some clues from you.


* can i use a simple osg::texture2D (nearest neighbour worldcoordinate scaled 
to osgforest's terrain extent), as raster mask?

* if yes, how can i query/access a raster value at a specific texture 
coordinate?

* how can i prevent that the raster mask will be rendered in the final scene? 
(would a nodemask be the right way, or are there any better/simpler ways?)

* in this first approach i will only implement 2 different tree regions: 
covered and non-covered. my plan is to extend to the existing createTreeList 
function with a simple check for the raster mask value at the randomly 
generated tree position coordinates. only if it happens to lie inside a 
tree-covered area, the tree will be pushed into the trees list. maybe someone 
knows a more elegant way? 


best regards,
christian

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=7664#7664





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org