This is more of a general approach question, rather than the code issue. Let’s say I have a map with generated tiles using wonderful ninth’s script here [Creating a tiled mesh at runtime). He creates 3 geoms, because that’s the number of textures that is set up in the beginning. Or I create each tile as a separate geom and call flattenStrong in the end, that would result with also only few geoms.
Now, I am using another wonderful script for picking by rdb [Super-fast mouse ray collisions with ground plane). I would like to visually display where my mouse is, by lets say changing the texture of the underlying tile. If I did my terrain like above, is it true I cannot change just one tile’s texture because it is now part of a larger geom? Could I destroy the geom and create a new one without the tile I want selected, and then create just that tile with different texture? I’m guessing this would not be very fast…
Any other ideas?
Make a copy of the tiles befor flattenig them and detach it from render. Then when you select a tile, or when you know what tile to select, make again a copy of all tiles without that selected one and flatten them. Now you only need to trash the old tiles, attach the new tiles and that single selected tile to the render. You’ll get all the unselected tiles flat and the selected one as a stand alone node that you can change.
Do this only when needed or it will kill your framerate.
If you only want to visually display where your mouse is, why not just have another model made of just one tile follow your mouse, and placed a little above the ground (e.g. setZ(0.01) )?
You can set some transparency on it to keep the tile of the bigger geom underneath visible.
That is what I was doing so far, but now I will have need to mark more quite a few tiles (to display available movement paths etc) so I will try to dinamically create and destroy smaller flattened pieces of the terrain.