Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Unity 2022.2 is now available as the latest Tech release.
    Dismiss Notice
  3. We are making some changes to the DOTS forums.
    Dismiss Notice
  4. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice

World Building [RELEASED] CScape - advanced building generator

Discussion in 'Tools In Progress' started by olix4242, Mar 11, 2017.

  1. JamesWjRose

    JamesWjRose

    Joined:
    Apr 13, 2017
    Posts:
    601
  2. JamesWjRose

    JamesWjRose

    Joined:
    Apr 13, 2017
    Posts:
    601
    @olix4242

    Got "Generate Buildings" working, however I have a ton of ! messages and I thought I would ask if these are anything I should care about:

    Combine mesh instance 42 is null.
    UnityEngine.Mesh:CombineMeshes (UnityEngine.CombineInstance[])
    CScape.CSArray:MergeMeshes () (at Assets/CScape/Scripts/CSArray.cs:364)
    CScape.CSArray:UpdateElements () (at Assets/CScape/Scripts/CSArray.cs:311)
    CScape.BuildingModifier:ModifyBuilding () (at Assets/CScape/Scripts/BuildingModifier.cs:752)
    CScape.BuildingModifier:UpdateCity () (at Assets/CScape/Scripts/BuildingModifier.cs:366)
    CScape.StreetModifier:GenerateBuildings () (at Assets/CScape/Scripts/StreetModifier.cs:1077)
    CScape.CityRandomizer:GenerateSlantedBuildings () (at Assets/CScape/Scripts/CityRandomizer.cs:1094)
    CScape.CityRandomizerEditor:OnInspectorGUI () (at Assets/CScape/Editor/CityRandomizerEditor.cs:467)
    UnityEngine.GUIUtility:processEvent (int,intptr,bool&)

    Thanks
     
  3. Barritico

    Barritico

    Joined:
    Jun 9, 2017
    Posts:
    363
    Hi.

    How can I get a beta of the new version?
    Thank you.
     
  4. olix4242

    olix4242

    Joined:
    Jul 21, 2013
    Posts:
    1,939
     
    jeroll3d likes this.
  5. mjamie

    mjamie

    Joined:
    Sep 4, 2017
    Posts:
    11
    Is there any chance that the CScape works with URP or is this still in development?
     
    DavidZobrist likes this.
  6. Malintis

    Malintis

    Joined:
    Jan 25, 2019
    Posts:
    5
    For me, this works in editor but has problems in build. Sometimes none of the buildings at all change, sometimes only a few. I think this code requires a massive amount of calculating power in a short time, which causes problems.

    What would be a good For or While alternative to this code?
     
  7. JamesWjRose

    JamesWjRose

    Joined:
    Apr 13, 2017
    Posts:
    601
    "Editor" code is not to be used in a compiled app. My code is only to be used at design time. Affecting the Cscape buildings at run time is not a good idea.

    So, let's start with what EXACTLY are you trying to do?
     
  8. Malintis

    Malintis

    Joined:
    Jan 25, 2019
    Posts:
    5
    Hey, thanks for your reply! I made a button with which the player can live switch between a city with low, medium, or high buildings (int size). All buildings have the "Building" tag. This is the function that pulls it off in editor runtime:

    Code (CSharp):
    1. public void ChangeBuildings(int size)
    2.     {
    3.         var buildings = GameObject.FindGameObjectsWithTag("Building").ToList();
    4.  
    5.         foreach (var building in buildings)
    6.         {
    7.             var bldgModifier = building.GetComponent<BuildingModifier>();
    8.             bldgModifier.floorNumber = bldgModifier.initialFloorNumber + size;
    9.             bldgModifier.AwakeCity();
    10.             bldgModifier.UpdateCity();
    11.         }
    12.     }
    It's a lot to process at once so it takes a short moment to load (which is ok), but gets the job done in editor runtime. As a standalone app however, it often does either nothing or some (but always the same) buildings are affected. Each time I build the app, the effects seem different but never all buildings are affected.

    I figured it's just too much to drag through a foreach and needs to rely on a counting while or for function.
     
  9. JamesWjRose

    JamesWjRose

    Joined:
    Apr 13, 2017
    Posts:
    601
    The code looks fine. Thought I am not sure that you need both AwakeCity and UpdateCity. Try with just one of those.

    But since I didn't make the asset I can't say specifically why it doesn't work at runtime. That said, it is my understanding that Cscape is not really designed to be updated at runtime (I ABSOLUTELY could be wrong about this!) Olix should be the one to really say one way or another.

    Sorry.
     
  10. Malintis

    Malintis

    Joined:
    Jan 25, 2019
    Posts:
    5
    Thanks, you're right. UpdateCity seemed unnecessary and it takes a little less time to calculate. Unfortunately however the problem in the built app persists.

    In the best case I could use a slider to raise or lower the number of stories like you can easily raise and lower all buildings in editor with hardly any loading times, but as you said, Cscape isn't really designed for such purposes (and I think what I'm trying to do in most cases is hardly ever necessary anyway).
     
  11. JamesWjRose

    JamesWjRose

    Joined:
    Apr 13, 2017
    Posts:
    601
    Drats. Consider asking for help in Discord.
     
  12. JamesWjRose

    JamesWjRose

    Joined:
    Apr 13, 2017
    Posts:
    601
    Ok gang, I am having a issue and I am sure I'm am doing something stupid (feel free to point and laugh) I cannot make the city turn to nighttime. In this image: https://imgur.com/a/7t2vNh7 You can see the CScape Inspector on the left, the ONE light in the scene (inspector details on the right) is attached as CScape's sun. Yet when I affect the sun; it's position (above or below terrain), rotation, intensity, etc the city lights do not come on. Any clue?
     
  13. buc

    buc

    Joined:
    Apr 22, 2015
    Posts:
    99
    I had the same problem once, when I've experimented with a cloud solution. I've added it for testing and also disabled for further tests, but I've forgotten to replace the references. So I've changed the sun direction, but it was not the sun referenced in the CScape script. So this is at least one possibility and this simple thing can make you think there is a ghost in the machine :)
     
  14. JamesWjRose

    JamesWjRose

    Joined:
    Apr 13, 2017
    Posts:
    601
    I just changed the name of the "sun" in the hierarchy, cause JUST IN CASE, but yes the sun named on the CSLightsControl script did change to the same name as the sun in the scene. Thanks kindly for the thought.

    I created this project from a default HDRP project, so there is only CScape and Easy Roads 3D. I have never added any weather system.

    Again, thanks for the thoughts. Have a great evening
     
  15. JamesWjRose

    JamesWjRose

    Joined:
    Apr 13, 2017
    Posts:
    601
    Some good news; I resolved the 'night' issue.

    This may only be an issue with the current beta/HDRP. There is a scene included with the latest beta build; Assets/Cscape/CscapeHDRP Within that scene is the "Sky and Fog Volume" I dragged that object into the project and made it a prefab. I then went back into MY scene, created a new Directional Light (just in case) turned off all other lighting and lighting effects that are included with the default HDRP project, and then dragged the "Sky and Fog Volume" object into my scene. TADA! Nighttime. (I had also set the 'sun's transform properties in my scene to effectively the same values. My city is larger, so a little change in position was necessary)

    So, atm I do not know SPECIFICALLY which setting within "Sky and Fog Volume" resolved the issue, but I wanted to post back in case others have this problem. When/If I figure it out (as opposed to just moving on and not caring what the issue was now that it works.... so bad, I know) Anyway, when/if I figure it out I'll post specifics.
     
    buc likes this.
  16. JamesWjRose

    JamesWjRose

    Joined:
    Apr 13, 2017
    Posts:
    601
    Okay gang,

    I would like to place neon bars in various places on the buildings. ie: https://imgur.com/a/WzXCazO
    I have literally thousands of building (over 20K) and placing them manually would be awful. There are a number of different building meshes, so I can't just use a generic function to find the building's left, right and height.

    I spent the majority of the week working on a script, and it allows me to place neon bars at specific locations, but that is not working quite right. So before I dig farther in I thought I would ask if anyone has any thoughts?

    If you look at the attached image you can see that the building is an odd shape, and I would like the neon bars to be at specific locations, even if the building size changes. So any ideas are appreciated

    Have a good weekend
     
  17. buc

    buc

    Joined:
    Apr 22, 2015
    Posts:
    99
    You could access the vertices of the mesh via standard unity API.
    Then you need to create some base methods which are of your interest, like
    - give me the vertices with the highest value on the specified axis (so y would be used for the building height, for example)
    x and z in order to get the building's outer parts
    - and then you can combine different methods to filter, so the topmost points that have Y higher than a 2/3 of the building height and most outer on the x-axis
     
    JamesWjRose likes this.
  18. JamesWjRose

    JamesWjRose

    Joined:
    Apr 13, 2017
    Posts:
    601
    Good thoughts. Thank you very much.
     
  19. buc

    buc

    Joined:
    Apr 22, 2015
    Posts:
    99
    You're welcome. I remember when I have used the vertices for my buildings I had to include some tollerance, because some vertices have not been completly at the same position, although I've used snapping tools in blender. So when I've checked which point is over my point with x = 3 (in order to detect a line) I've missed at the beginning the points with x = 3.00000001. For what reason ever.
     
    JamesWjRose likes this.
  20. unity_nD7ijHGn9aGW7Q

    unity_nD7ijHGn9aGW7Q

    Joined:
    Jun 18, 2022
    Posts:
    1
    Hey I've just purchased this pack, it looks indeed awesome.

    I was wondering if it's possible to export a city mesh with textures on it ? I couldn't find any solution for this...
     
  21. buc

    buc

    Joined:
    Apr 22, 2015
    Posts:
    99
    What you see as the "texture" is completly assembled by the shader. The used technique allows to take something simple like just a 1m x 1m cube and render it as a skyscraper. This is where the beauty and the performance comes from, but also the reason why you can't export it (the exported mesh would be just this simplified empty mesh).
     
    olix4242 likes this.
  22. olix4242

    olix4242

    Joined:
    Jul 21, 2013
    Posts:
    1,939
    This is true. Also, even if it was able to export everything as a mesh for usage in other software, it would be against EULA. By buying Cscape, you have a licence to use it inside unity engine, not other engines/renderes. You have right to use Cscape only in Unity Engine.
    If you still need a way to use exported meshes in Unity, there are coming some fixes in latest veraions that will enable exporting meshes in FBX format for ater reimporting in Unity.
     
  23. kukuhbasuki

    kukuhbasuki

    Joined:
    Apr 13, 2016
    Posts:
    29
    Hi, I can't join your discord channel.
     
  24. buc

    buc

    Joined:
    Apr 22, 2015
    Posts:
    99
    There are multiple links, but I think the one below is the invitation link.
    https://discord.gg/mfBQQDGTAg
     
  25. jasonbtompkins

    jasonbtompkins

    Joined:
    Mar 4, 2019
    Posts:
    8
    I am looking to have multiple sections in a city in a night time scene. My first thought was to create two 10 x10 cities but I quickly discovered an issue. When I move one city, it affects the lighting of the other one. I tried having both cities using the same Re Lighting camera and Re Lighting Control Texture and increasing the boundaries of the camera and the reflection probe, but this resulted in reducing the intensity of the light on both cities. Is there something that I am missing where I can have more than one city in one scene that have there own independent lighting?
     

    Attached Files:

  26. jasonbtompkins

    jasonbtompkins

    Joined:
    Mar 4, 2019
    Posts:
    8
    Also, each block has streets rendered on only two sides resulting in two sides of the city having no streets. It would be nice if the city could have streets on all sides. Is there a solution for adding / extending the streets?
     

    Attached Files:

  27. Malintis

    Malintis

    Joined:
    Jan 25, 2019
    Posts:
    5
    I was wondering if there are any plans of implementing this in the future, but maybe it would require too much of an overhaul of the system since Street objects at the moment don't separate sidewalks from roads.

    It would make it a lot easier to bring the city to life with traffic though!
     
  28. JamesWjRose

    JamesWjRose

    Joined:
    Apr 13, 2017
    Posts:
    601
    Not the answer you are looking for... I use the asset Easy Roads 3D as the roads for my game. It allows for curves and has data for lanes that can be used for traffic.