Posts

Showing posts with the label ArchitectureAIProject

Architecture AI Pathing Project: Fixing Highlight Selection Bugs

March 22, 2021 Highlight Selection Architecture AI Project Overview I was having a bug come up with our selection highlight effect where sometimes when moving around quickly, several objects could be highlighted at the same time. This is not intended, as there should ever only be a single object highlighted at once, and it should be the object the user is currently hovering over with the mouse. Bugfix Assessing Bug Case Since it happened generally with moving around quickly in most cases, it was difficult to nail down the direct cause at first. After testing a while though, it was noticeable that the bug seemed to occur more often when running over an object that was non-selectable, onto a selectable object. Further testing showed this was the case when directly moving from a non-selectable to a selectable object right afterward. This helped isolate where the problem may be. Solution It turns out in my highlight selection SelectionManager class, I was only unhighl...

Architecture AI Pathing Project: Cleaning Build UI

Image
March 15, 2021 Working with UI Architecture AI Project Working with UI Since UI looked organized into 4 major groups vertically, I used a Vertical Layout Group for the overall control. I then filled this with 4 empty UI objects, one for each major UI group. Vertical Layout Group Anchor Preset: stretch/left (anchors to the left, but expands for full vertical screen space) Pivot: (0, 0.5) (Moves pivot point to the far left, so width controls how much it expands out from edge, and Pos X can just remain 0) Child Force Expand: Width (Helps expand everything to fit the full width) Child Force Expand: Height (May not be needed) Control Child Size: Width (May not be needed) Padding: Left, Top, Bottom (Keep everything slightly away from edge) Controlling the anchors and pivot is extremely important. After setting up the vertical layout group, a lot of the individual control is necessary for the horizontal organization. The anchors, the x position in particular, can be ...

Architecture AI Pathing Project: Fixing Weird Build Bugs

March 11, 2021 Build Issues Architecture AI Project Overview After working on the project with a focus on using it in Editor for a while, we finally decided to try and see if we could build the project and work with it from there. Initially it did not provide anything useable. It would build, but nothing could be done. After a while, I isolated that the colliders were giving trouble so I manually added them for a time and that helped set up the base node grid. The file reader however was unable to provide data to the node grid, so only one aspect of applying data to the pathing node grid worked. These issues made the build fairly unuseable, but provided some aspects to approach modifying in order to fix the build. After some work focusing on the issue with applying colliders and reading/writing files, I was able to get the builds into a decently workable spot with hope to get the full project useable in a build soon! Unable to Apply Colliders with Script: Working wit...

Drawing and Rendering Many Cube Meshes in Unity

March 02, 2021 Drawing and Rendering Meshes Unity Title: Drawing 1 Million cubes! Unity - Forum Description: Discussions and code for drawing and rendering many cube meshes. Overview I wanted to be able to replicate the drawcube Gizmos in Unity I am using to portray data for my architecture project in the game scene and eventually builds of the project. To do this I need a very lightweight way to draw many small cube meshes, so I looked into drawing/rendering my own meshes and shaders. This option I came across in a Unity forum to just draw and render meshes on Update seemed decent enough so I investigated a simpler version for my needs. Implementation I could get away with a much simpler version of the CubeDrawer script found in the forum comments. I could strip out the batching and the randomization as I need very specific cubes and no where near the million cubes they were rendering. I am normally looking at somewhere in the thousands to ten-thousands, ...

Architecture AI Pathing Project: Rename Dropdown Elements

Image
February 16, 2021 Dropdown and Input Field UI Architecture AI Project Renaming Items in Spawn/Target Dropdown Lists To get the spawn/target object lists into the dropdowns quickly and accurately, I had them simply add their gameobject names to the dropdowns for the individual item names. These objects however tend to have very long names as they are constructed from several elements coming from the Revit system to accurately identify them. While useful, they are too wordy for identification purposes here and can actually make them harder to find and keep track of. Because of this, we wanted to investigate a way to rename the elements in the list to make them easier to identify in the future. To accomplish this I looked to add a UI Input Field where any name could be entered and this could be used to rename current items in the dropdown lists. Since there are two dropdowns (Spawn list and Target list), I added two different buttons to account for these. One button applies...

Architecture AI Pathing Project: Upward Raycast for Better Opening Detection

Image
January 11, 2021 Raycast for A* Nodes Architecture AI Project Original Downward Raycast and Downfalls The raycasting system for detecting the environment to setup the base A* pathing nodes was originally using downward raycasts. These rays traveled until they hit the environment, and then set the position of the node as well as whether it is walkable or not. An extra sphere collision check around the point of contact was also conducted so as to check for obstacles right next to the node as well. This works for rather open environments, but this had a major downside for our particular needs as it failed to detect openings with in walls and primarily doors. Doors are almost always found within a wall, so the raycast system would hit the wall above the door and read as unwalkable. This would leave most doors as unwalkable areas because of the walls above and around them. Upward Raycast System Approach Method The idea of using an upward raycast was that it would help al...

Architecture AI Pathing Project: Revit Data Applying Helper Class

December 9, 2020 File Reader Architecture AI Project Enhancing the Extendability of the Revit Parameter Data Application Class through Helper Class I got the basics of reading in a specified set of parameter data from Revit to apply to the model in Unity, but we would need to have options for possibly using many sets of data from there. To handle this I wanted to make it easy to add ways to handle all the differents types of logic with these sets of data. This started by creating a foundational interface that any class utilizing the data would implement, but I also needed a way to tie these specific classes to their corresponding data sets. I ended up doing this mostly with a helper class, named RevitModelDataHandlerManager, to the CSVReaderRevitModel class. Connecting Specific Data Handler Classes with Specific Data Sets Using a Dictionary Because of the nature of this data, we know that we will be searching for several different specific strings somewhere along the way,...

Architecture AI Pathing Project: Applying Revit Parameter Data to Model in Unity

December 8, 2020 File Reader Architecture AI Project Applying Revit Parameter Data to Model in Unity After reading the Revit parameter data into Unity, it could now be used to modify the model within Unity itself. The original goal was to read the data to determine which objects within the model should be placed on which Unity layer, specifically the "Unwalkable" layer in most cases. It should then be extended to be able to add components to specific objects as well, meaning it needs to have a diverse functionality set available when modifying these individual objects. Building Data Arrays as Dictionaries for Flexibility Since the full extent of the use of this data is not fully known yet, having a flexible and extendable option for organizing and searching through the data made sense here. As the data is read in one sheet at a time and placed into separate 2D string arrays, I decided to organize those 2D arrays within a dictionary. The key of these dictionaries...

Architecture AI Pathing Project: Another File Reader for Revit Model Data

December 3, 2020 File Reader Architecture AI Project Another File Reader: Revit Model Data After reconstructing the file reader to read in various coordinate data to be passed on to the A* pathing node grid, we also needed a file reader to read in data from the Revit model itself to reapply that data to the models in Unity. Revit allows the user to apply many parameters and lots of data to the models contained within it, and that data can be exported as a large Excel file. That data however is not being passed into Unity when exported as an .fbx file, so we needed a way to reapply that data using the exported data. Goal While this is a flexible enough concept to apply many parameters, the main problem this system is being created to solve was automating the process of labeling what parts of the model are "walkable" or "unwalkable". I had created a system to somewhat help do that in Unity, but this system will allow the user to do that work on the Revit...

Architecture AI Pathing Project: File Reader and Different Resolutions of Data and A* Pathing Grid

December 1, 2020 File Reader Architecture AI Project File Reader Data Array Creation The file reader for this projects starts with the CSVReader class. This class is responsible for reading data in from .csv files generated by Revit to pass it on to the underlying A* pathing node grid for use by the agents when pathing. These .csv files have 2D coordinate values to locate the data, the actual data value, and a reference ID. The coordinate data and the data values themselves are separated and saved into many data objects within Unity (in a class named DataWithPosition). This prepares the data to be used to pass on to the A* pathing node grid. While the .csv data is generally consistently spaced based on coordinates, it can have many gaps as it does not assign a value somewhere where there is a gap in the model. This results in data that is not perfectly rectangular. To make the process of tying this data array in with the pathing grid more consistent, I manually make a recta...

Architecture AI Pathing Project: Selecting Spawn and Target Positions from Objects in the Model

Image
November 23, 2020 Spawning and Pathing System Architecture AI Project Updated Spawning System to Use Objects within Model as List of Options We wanted to update the spawning system so that instead of being arbitrary points, both the spawn location and target location were tied to objects that could be found throughout the entire model. The system is already creating a list of all the objects within the model for applying colliders and various other components, so that could be accessed for this purpose as well. This list of objects was then put into a UI dropdown for selecting both the spawn position and the target position. The transform of the selected object was then used for that respective part of the pathing. Highlighting the Spawn and Target Locations I wanted to highlight both the spawn and target objects to make it more apparent where the agents would be aiming to path. The first implementation I went with for now changes the material of the object. The spawn obj...

Architecture AI Pathing Project: Automating the Sizing of the Node Grid

Image
November 17, 2020 Automated Node Grid Size Architecture AI Project Title: Unity Bounds Documentation By: Unity Unity - Informational Description: Unity's documentation on their Bounds class and its methods. Automating Process of Sizing the Node Grid The A* pathing uses an underlying grid of nodes to inform the agents how to move through an area. A value must be input to tell the grid how large of an area to cover with these nodes. Originally these values, which are two dimensions of a rectangular area, had to be input manually. Since this grid will always be covering a full architectural model, it made sense to be able to access the model and automate the sizing process through the size of the model. Encapsulate Bounds of All Children Objects Since we are dealing with models in Unity, I looked to the Bounds class to help with automating this grid creation process. Immediately, Bounds can be used to find the bounding volume of a single mesh/renderer/c...

Architecture AI Pathing Project - System Manager and Automating Component Application to Imported Models

October 29, 2020 Automating Component Application and System Manager Architecture AI Pathing Project System Manager and Initialization The integration of several classes and adding more has started to create a lot of necessary references becoming difficult to time properly. To make sure a certain class has already initialized or some other class has performed its Awake() method I end up making extra references and method calls within other classes so the proper references are set before peroforming those methods. In an effort to organize this better and make the timing more understandable, I am looking at making a SystemManager gameobject to replace the DemoManager, and either add an Initialization class to this or make it its own class if it does not require being a monobehaviour. This Initialization class will be responsible for calling all the major system classes initialization methods in the proper order to ensure references are met. This will also require moving som...

Architecture AI Prototype Historical Path Visualization and UI Updates

Image
July 1, 2020 Architecture AI Project Added Path Visualization and UI Updates Introduction To top off the prototype, we added a quick visualization tool to show any paths that agents have taken within the current game session. This was necessary to make it easier to compare the paths of various combinations of agents and environments even. Along with this, some elements of modifying the system that were only accessible within the Unity Inspector have been moved to the in game UI. This makes it much more manageable to alter the agents and their pathing for Unity users and non-users alike. The following quick reference image shows an example of this new path visualization tool (the red line going through the diagonal of the area). Reference for New Path Visualization Tool (the Red Line is the Path) Vimeo - My Demo of the Past Path Visualization Tool (with New UI Elements) Past Path Visualization Feature Visualization The path data was already being recorded in an ...

Architecture AI Completed Prototype with Data Visualization and Pathing Options

June 24, 2020 Architecture AI Project Completed Project Prototype Introduction We were exploring different methods for importing architectural models into Unity and decided to try Revit to see what it had to offer. The models are easy to move between softwares, and it also creates .cs scripts that Unity can use to provide some interactive data visualization when using the Revit models. Data Visualization Options I moved everything dealing with the major logic of the A* grid node visualization into its own class named AStarGridVisualization. This allowed me to continue to hold on to all the different debug visualization methods I created over the course of the project and convert them into a list of options for the designer to use for visualization purposes. As can be seen in the demo, there is a list of options in the drop down list in the Unity Inspector so the designer can tell the system which data to visualize from the nodes. The options currently available are: Wa...

Architecture AI Working with Revit Models and Scripts in Unity

Image
June 15, 2020 Architecture AI Project Revit Models in Unity Introduction We were exploring different methods for importing architectural models into Unity and decided to try Revit to see what it had to offer. The models are easy to move between softwares, and it also creates .cs scripts that Unity can use to provide some interactive data visualization when using the Revit models. Parameters Import Script This script creates a large list of strings. It does so by receiving an identification looking string, and uses a method to convert that string into its corresponding parameter information. Example: private string ParamByName(string d) { switch(d) { case "Generic_-_12\"_[354721]": d = "Area : 8100 ft2 \nElevation at Bottom : -1 ft \nElevation at Top : 0 ft \nType Name : Generic - 12\" \n"; break; ... } return d; } Parameter Mouse Over Script This script uses the name of this.gameObject to add information to t...
Image
Architecture AI Reading CSV File Data to Use in Node Grid June 8, 2020 Architecture AI Project Read CSV File General Goal For this architecture project we wanted to be able to read data exported from other softwares into Unity. Initially we will be using data from Rhino, but it will be converted to a very generic format (like .csv), so it should be more widely applicable. This data will be used as another way to inform the node system and assign architectural values to these nodes which will again be used to inform the decisions of the agents traveling with the node system. Using Text Data in Unity Our text files will be very simplistic, so we can use a very straight forward approach to organizing and using the data from the text files. Each line of data is important for a single node, so splitting on a line will help organize individual node information. Then we just have to split up the information within that line to spread the information out to the proper variables wi...

Architecture AI Varied Agent Affinities with Varied Pathing

May 28, 2020 Architecture AI Project Varied Agent Affinities with Varied Pathing Demonstration of Varied Agent Affinities with Varied Pathing Vimeo Link - My Demo of Agents Pathing with Varied Affinities Explaining Simple but Unclear Heatmap Coloring System Just to help explain since I don't have great UI in to explain everything currently, the first thing was that I was testing a really rough "heat map" visual for the architectural values for now. When you turn on the option to show the node gizmos now, instead of uniform black cubes showing all the nodes, the cubes are colored according to the architectural value of the node (for this test case, the window value) Unfortunately this color system isn't great, especially without a legend, but you can at least see it's working (I just need to pick a better color gradient). Red is unfortunately both values at/near 0 (min) as well as at/near 100 (max) (but the value range here is only from 0 - 80, so all r...

Architecture AI Heatmap of Architectural Costs

Image
May 27, 2020 Architecture AI Project Visualizing Heatmap of Architectural Costs Architectural Cost Heatmap I was just using basic black cubes to visualize the grid of nodes in the AGrid A* system originally. Now I finally decided to update that system with a bit more information by adding a colored heatmap to map out the architectural values of the nodes. This will help me understand the pathing of my agents better as they start to use these values in more complex and interesting ways. Basic Heatmap Color System It turns out making a heatmap color scale that decently ranges between values of 0.0 and 1.0 is pretty easy. Using HSV color values, you can just vary the H (hue) value while keeping the other two values constant at 1.0 to cover a heatmap spectrum (where H of 0.0 is the lowest value in the range, 1.0 is the highest value in the range, and all other colors are bound within that range). By simply using the min and max architectural values possible in the system as the...

AGrid Inspector Breakdown for A* Pathfinding

Image
May 5, 2020 A* Pathfinding AGrid Inspector Breakdown Display Grid Gizmos: determines whether or not to run gizmo methods (methods used for debugging and visualization in the editor, like the node locations) Unwalkable Mask: this is the Unity layer that is deemed unwalkable to the system (the layer which are picked up by the nodes during raycasting) Grid World Size: a Vector2 which determines the real world size area to attempt to place nodes on (rectangular shaped with alterable width and height) Node Radius: half the real world size of each individual node, which correlates to half the distance between each node's center (in both the x and z direction) Walkable Regions: this section can be opened and various terrain types can be added to this as well as their associated movement cost penalties to make certain terrains more or less navigable (also picked up in the raycast of the nodes) Obstacle Proximity Penalty: adds a bit of ext...