Created
November 6, 2017 14:26
-
-
Save zaneclaes/ee72e2ff7d4ac3d0430c4f62f707c346 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MeshRenderBoneComposition comp = | |
creatureAsset.creature_manager.target_creature.render_composition; | |
List<MeshRenderRegion> regions = comp.getRegions(); | |
foreach (MeshRenderRegion region in regions) { | |
Rect r = new Rect(); | |
int uvIndex = region.getUVsIndex(); | |
for (int i = 0; i < region.getNumPts(); i++) { | |
Vector2 p = new Vector2(region.store_uvs[uvIndex], region.store_uvs[uvIndex + 1]); | |
if (i == 0) { | |
r.xMax = r.xMin = (float)p.x; | |
r.yMax = r.yMin = (float)p.y; | |
} else { | |
r.xMin = Mathf.Min(r.xMin, (float)p.x); | |
r.xMax = Mathf.Max(r.xMax, (float)p.x); | |
r.yMin = Mathf.Min(r.yMin, (float)p.y); | |
r.yMax = Mathf.Max(r.yMax, (float)p.y); | |
} | |
uvIndex += 2; | |
} | |
// Now, r should be the UV box for the region... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment