Using bounding box boolean to create a random 'subtraction' effect. Applied to a pretty standard octree scene management system.
What's happening is basically the program is 'cutting' into the objects in the scene and generating new replacement parts (new bounding boxes)
The goal of this test is to just make sure the logic is sound.. not very efficient.
I came across this little snippet of code* to find the next power of 2 and found it quite helpful – from what I understand it's also very efficient compared to other methods.
public int NextPowerOfTwo(int inInt)
inInt = ( inInt >> 1 ) | inInt;
inInt = ( inInt >> 2 ) | inInt;
inInt = ( inInt >> 4 ) | inInt;
inInt = ( inInt >> 8 ) | inInt;
inInt = ( inInt >> 16 ) | inInt;
inInt++; // Val is now the next highest power of 2.
Link to original article regarding technique and actually a more detailed explanation of the method – Acius' Snippets.
So here we go.. a quick recorded version.
Since Unity doesn't really have an elegant solution to a 'user file open dialog' I've decided to go to a more source file update type method.
So basically there's a file in the directory with the application called 'gameSource.txt' and the app with automatically load and refresh the scene with this map data when the file is changed. So if you have a simulation output the results into this text file the visualizer will automatically load the file and play the new simulation.
Why is this good? Because it means you don't have to restart the visualizer it can stay open the whole time playing while you work away and will update when there's new game data.
So i cleaned up some of the code and added some aura type objects behind the planets. This really is so I can have a more subtle color on the planet without losing the indication that the planet has been converted.
Seems like some of the auras are doubling up on the blue side – something is causing them to change hue.
Next up I'm going to work on getting some UI controls: "play", "pause", "goto beginning", "goto end"
Added GUI text components for the planets and the fleets. I tried with 3D text but the results are true 1:1 pixel ratio for the text rendering so you get aliasing artifacts.
To get the GUI text in the right position I had to do a double transform. Once to Camera pixel space and then to camera viewport space (basically 0,0 to 1,1 extents representation of the viewport)
Vector3 screenPos = gameCamera.ScreenToViewportPoint(gameCamera.WorldToScreenPoint(pos));
Oh and I whipped up a quick ship model to use rather than the capsule I was using before