|
Post by kramar on Sept 9, 2015 12:07:33 GMT
Hi again. So I am experimenting with custom terrain textures and foreground objects and I have noticed two problems when recreating the atlas. I tried creating a new atlas and it works fine when generating and saving a new map. However, if I make changes to the atlas they do not take effect when re-loading a saved map (whereas texture changes do). It ends up having no foreground objects at all. Is there any way to make a saved map use the new atlas? Second, I found something weird when creating the atlas. I re-sized the texture in unity, but when I drag it into the atlas editor it reverts back to its intrinsic size. Is this a bug? Thanks
|
|
|
Post by khash on Sept 12, 2015 12:11:12 GMT
Foreground atlas have its own editor, its easier if you would use it. It stores more than just texture so if you change texture outside (not only content but as well size) you will get issues, yes. Note that changes in the atlas my change many settings and what you see as "no foreground" my simply be offsync between position of the tree it expect.
World remembers "name" of the foreground to be drawn so the offsync had to happen on unity asset level (eg, making changes during runtime) I have no Unity on current machine so its a bit of the guess game for me but that's what I would guess from your issue description
|
|
|
Post by kramar on Sept 16, 2015 12:21:48 GMT
Let's forget the atlas editor for a minute. I didn't know there was a way to re-size the foreground textures in the editor. I will check.
The bigger problem is save/load of grids. So I have a terrain definition, generate a world and save it. I stop running the scene. Next, in the terrain editor, I am keeping the same name for all terrains types. I edit the textures and use a new foreground atlas and save it. When I run and load the saved World, it uses the edited textures, but it is indeed still trying to use the old foreground names so I get no foreground objects since it can't find it.
Are you saying the saved grid will never be able to use a new foreground atlas once it has been saved?
|
|
|
Post by khash on Sept 16, 2015 22:49:38 GMT
When you generate word it as well uses terrain definition to produce foreground. It remember foreground setting and name which is later used for restoration. If you add new trees to the atlas it should be fine, but if you remove those which were there before there is no way to replace them. But note that there is nothing agains refreshig foreground data, and for this it would use those linked in the editor so if for example you had terrain with dead trees and you want to remove them and add living green trees you can force this hex to recreate its foreground data after updating this in the terrain data editor. Same goes for number of trees or colors... you can change green color style to white and make your trees look like covered in show...
Does it answer your question?
|
|
|
Post by kramar on Sept 17, 2015 12:04:22 GMT
Hi Khash,
Yes it does answer my question and that's exactly the way I would like it to work.
I guess what I'm missing how to force all the hexes to recreate their foreground data. I thought that just re-loading the grid from disk while using the new atlas and terrain definition would work. It does work for the textures, but NOT for the foreground objects.
|
|
|
Post by khash on Sept 17, 2015 19:02:51 GMT
I think the fastest way to get some updates on the foreground (much faster than reloading) is following "PaintTrees" example in CameraControler.cs: //EXAMPLE1: Color radius or trees //World.PaintTrees(new Vector2(hitPoint.x, hitPoint.z), 3f, new Color(1f, 1f, 0f)); simply uncomment this part to see how it works. You may want to make it more robust but this should be good starting point. Much more complex rebuild is done with Example3 which rebuilds selected hex with all the foreground on it to some other random type (eg changes mountain to swamps and replaces all the foregroud it had to the one defined in the editor) One or the other example should do the job for you
|
|
|
Post by kramar on Sept 18, 2015 14:33:00 GMT
Thanks for pointing me in the right direction. I will take a look...
|
|
|
Post by kramar on Sept 23, 2015 11:48:56 GMT
I finally got a chance to try Khash's suggestions.Took me a couple of tries, but I finally got it working.
In case anyone needs it, I used the following:
foreach (Hex hex in World.instance.hexes.Values)
{
//Don't regenenerate foreground if it is a sea hex
if (hex.terrainType.source.seaType)
continue;
World.instance.ReadyToPolishHex(hex);
hex.RebuildChunksOwningThisHex();
}
base.RebuildDirtyChunks();
Thanks again for the help Khash.
|
|