Quantcast
Channel: Latest Questions by Griffo
Viewing all articles
Browse latest Browse all 94

Divide volume depending on chosen amount.

$
0
0
Hi, I'm a bit stuck and could do with some help please, I've put together a script to find the bounds of a prefab that helps me place light probes but what I'd like to do is if I ask for 2, 3 or 4 light probe volumes I'd like to divide the bounds up like in the pictures below, any ideas on how to efficiently do this, thanks. function findBounds () { ClearBounds(); probePositions.Clear(); var allChildren = transform.root.gameObject.GetComponentsInChildren(Transform); for ( var child : Transform in allChildren) { if(child.gameObject.GetComponent.() != null) meshRenererArray.Add(child.gameObject.GetComponent.()); } for (var i: int = 0; i < meshRenererArray.Count; i++) { boundsArray.Add(meshRenererArray[i].bounds); _center += meshRenererArray[i].bounds.center; } //center is average center of children _center /= transform.root.childCount; totalBound = new Bounds(_center, Vector3.zero); for (var ii: int = 0; ii < boundsArray.Count; ii++) { b = new Bounds(boundsArray[ii].center, boundsArray[ii].size); totalBound.Encapsulate(boundsArray[ii]); } transform.position = totalBound.center; for ( var area: LightProbeArea in LightProbeVolumes) { area.ProbeVolume.extents = totalBound.size; area.ProbeVolume.center = totalBound.center; } } ![alt text][1] [1]: /storage/temp/83091-cubes-00.jpg

Viewing all articles
Browse latest Browse all 94

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>