Does anybody know a surefire way to apply a texture to Terrain?
I’ve only seen one example & this doesn’t seem to work.
Thanks
Does anybody know a surefire way to apply a texture to Terrain?
I’ve only seen one example & this doesn’t seem to work.
Thanks
Depends which terrain you have in mind. If you refering to Terrain included in Xith3d then I cannot help you I guess only Dave would have something to say about that since he is author of it.
But I can tell you how I did it in my app. I do use similar (even though) simplified hack at it. I use qudtree as well to get geometry, then I copythat geometry into smaller patches(tiles) and only then I start applaying textures. Each tile ends up being one shape3d object. Example you saw here put everything into one shape3d object and I assume that is just done to create demo - i dont see any way how one could do good looking texturing but placing one huge texture on the top of it. Unless texture - or subpart is recreated every frame. That is just wild guess, maybe there is a intelligent way of doing that.
Basically I am saying you most likely will have to twist demo a bit to get to point where you can start thinking of putting textures on it.
I’d like to know the explaination from the Xith Terrain side too… how does this work with one big Shape3D?
Eric
Found this interesting post from 2/3 weeks ago which might help us a little:
I’m really looking to just place textures on the whole thing or better still have three different textures depending on the height, a bit like the results of terrain generators mojo created in his jME 0.1 that allowed you to do this.
Don’t forget that the Xith terrain system is a matrix of banks with 2(n-1) levels…I think! so you probably want several different textures based on resolution.
The Terrain system is a terrain geometry system. The demo just demonstrates how to use that in the simplest possible scheme.
The way Magicosm uses this is as follows:
We create a logical quadtree which has as its smallest quad 100x100, which each subsequent level being doubled. We have a table which describes the minimum distance from a sphere surrounding the user that any particular level can be visible.
We preprocess a set of blending masks 64x64 for each level 0 quad and calculate, using those masks merged texture maps for the other levels. The level 0 masks and the level 1+ textures are stored in a file.
Every 10 meters of movement in the world we step through the quads and see if any quads need to be added or removed. This builds a transaction which adds or removes QuadNodes. A quad node is a branchgroup that has either a single shape + texture + detail, or a level 0 shape, which is an ordered group of SplatShapes. Splat shapes use COMBINE mode to combine the mask and the texture and then merge it with the underlying texture. There can be any number of splat shapes on one tile.
Each quad node needs geometry, but the geometry is being stored in a Terrain node and updated frequently. What we do is when we call Terrain.render we pass it a callback. This callback is called with chunks of geometry. We sort this geometry into buckets and assign them to the appropriate QuadNode. If a triangle spans two QuadNodes we split the triangle using a triangle splitter. Thus each quad node has access to its geometry all the time and can still texture its piece itself.
[quote] A quad node is a branchgroup that has either a single shape + texture + detail, or a level 0 shape, which is an ordered group of SplatShapes. …
[/quote]
So you do use ordered group. Now that is at least for me the most valuable info. 
Tried this, but it only textures the lines between the triangles not the surfaces. Any idea how I can texture the surfaces ???
tomcat
Ok, managed to workout how to fill the area with the texture map, but discovered that the example doesnt allow tiling of the texture. :-/
Is it possible to tile a texture to the terrain ???.
tomcat
change POLYGON_LINE to POLYGON_FILL .
I have done this. But this doesnt solve the tiling problem. I get the same texture stretched across the whole terrain instead of being tiled to each polygon. Any ideas whats happening?
tomcat
sure it does that. Texture coord are stretched from 0-1 in xz plane. Thought that is what you want. If you wanna just repeat one tile dont set texture coord and that should do it.
Sorry for being a bit thick here, but I dont set the texture co-ordinates. I have used the Terrain example from sith3d and made some simple modifications. Here is some of the things I have done
Any ideas what I am doing wrong ???
tomcat
I thought you were refering to aforementioned example not to Terrain example. Sorry I have not looked at that one yet AFA texturing goes.
By default the texture maps from 0,0 to 1.0,1.0 in S,T coordinates (think of this as 0 to 100% in each direction). To tile the texture you can adjust the mapping to get NxN tiles.
I have written a small tutorial over at xith.org with source showing just this. Go to here to see how to adjust the coords
http://xith.org/tutes/GettingStarted/html/more_fun_with_textures.html
Use this WebStart (thanx Jens) to see the tiling update realtime
Thnx, it does make sense. I checked out your code sample, but I am not sure where I
[quote]To tile the texture you can adjust the mapping to get NxN tiles.
[/quote]
should make the change. ???
tomcat
Basically if you have the Shape you can grab the tex coords set them to different values. The first arg of setFloats is the array index
GeomDataInterface texCrds1 = quad.getTexCoordData(0);
texCrds1.setFloats(0, 0.0f, 0.0f);
texCrds1.setFloats(2, 10.0f , 0.0f);
texCrds1.setFloats(4, 10.0f , 10.0f );
texCrds1.setFloats(6, 0.0f, 10.0f );