Gassloader over paged terrain

xelons

11-07-2012 00:32:31

Hey guys,
I just started using pagedgeometry and its absolutely great.
I have successfully compiled it and run the examples with no problem.
My question is I have tried to take a look at the grassloader source code to get an idea on how its coordinate system works but Im still having problems.
My first question is how does setHeightFunction really works? I mean I know we need to pass a heightfunction to it in order for it to determine the y coordinate but that height function accepts x and z coordinates.
From where does grassloader get that x and y coordinates? I know that there is a setMapBounds function that specify the map boundaries but in the example 4 that function is called at the end, AFTER the setHeightFunction was called.

In my project I use a custom terrain paging based on voxels, to determine the height of a current page i use a special function that returns the height at a specific x and z location. I pass that function to the setHeightFunction and then I set in the setMapBounds my current page xstart zstart and xend zend. So basically I set a new grass layer for every terrain page after it being loaded.
Is this the right way to do it? seeing that my terrain is randomly generate using a noise function and its technically infinity.

In my case is there any other boundaries that I need to modify to bound the grass for every specific paged page?

m2codeGEN

11-07-2012 07:34:19

setHeightFunction just set pointer to function and some user data.
PagedGeometry use right handed coordinate system (0X right, 0Y up, 0Z from viewer).
When you call update method PagedGeometry can build some batches for grass and make callback with pointer to height function.

xelons

11-07-2012 07:51:10

setHeightFunction just set pointer to function and some user data.
PagedGeometry use right handed coordinate system (0X right, 0Y up, 0Z from viewer).
When you call update method PagedGeometry can build some batches for grass and make callback with pointer to height function.

That explains how the grassloader get's its x and z coordinates, my main problem here is about the height. My terrain is procedurally generated based on a noise function, it is made with voxels and I can easily retrieve the height at any given x and z. How can dynamically change the height of the grass loader depending on my paged terrain?

m2codeGEN

12-07-2012 08:26:42

After grass page (batch) is build you can`t change it (need full vertex buffer refill). Future more, voxels terrain can be represented as 3D matrix, but paged geometry 1.x can support only flat terrains (no caves).
You just can make smaller page size (10 units for example) if you have difficult with height retrieves.

xelons

13-07-2012 00:48:47

After grass page (batch) is build you can`t change it (need full vertex buffer refill). Future more, voxels terrain can be represented as 3D matrix, but paged geometry 1.x can support only flat terrains (no caves).
You just can make smaller page size (10 units for example) if you have difficult with height retrieves.

Thanks for your suggestions and explaination, 1 more thing, I'm trying to reduce the view distance of the grass, by that I mean I'm trying to reduce the number of pages loaded at the same time, how can I do that? I know that I can change a single page size but I need to change the number of loaded pages and reduce it.
Oups sorry I found it, its adddetaillevel function, now all I need to do is sync. the grass pages with my terrain pages. Sounds fun :/