public override void Modify(MegaModifiers mc) { Vector2[] uvs = mc.GetSourceUvs(); Vector2[] newuvs = mc.GetDestUvs(); if ( uvs.Length > 0 ) { Vector3 pos = -gizmoPos; Vector3 scl = gizmoScale; Vector3 rot = gizmoRot; Matrix4x4 tm1 = Matrix4x4.identity; Vector3 p = Vector3.zero; for ( int i = 0; i < uvs.Length; i++ ) { p.x = uvs[i].x - Offset.x - 0.5f; p.z = uvs[i].y - Offset.z - 0.5f; p.y = 0.0f; float d = Mathf.Sqrt(p.x * p.x + p.z * p.z) * spiral; rot = new Vector3(gizmoRot.x, gizmoRot.y + d, gizmoRot.z); tm1 = Matrix4x4.TRS(pos, Quaternion.Euler(rot), scl); p = tm1.MultiplyPoint(p); newuvs[i].x = p.x; newuvs[i].y = p.z; } } }
public override void Modify(MegaModifiers mc) { Vector2[] uvs = mc.GetSourceUvs(); Vector2[] newuvs = mc.GetDestUvs(); if (uvs.Length > 0) { Vector3 pos = -gizmoPos; Vector3 scl = gizmoScale; Vector3 rot = gizmoRot; Matrix4x4 tm1 = Matrix4x4.identity; Vector3 p = Vector3.zero; for (int i = 0; i < uvs.Length; i++) { p.x = uvs[i].x - Offset.x - 0.5f; p.z = uvs[i].y - Offset.z - 0.5f; p.y = 0.0f; float d = Mathf.Sqrt(p.x * p.x + p.z * p.z) * spiral; rot = new Vector3(gizmoRot.x, gizmoRot.y + d, gizmoRot.z); tm1 = Matrix4x4.TRS(pos, Quaternion.Euler(rot), scl); p = tm1.MultiplyPoint(p); newuvs[i].x = p.x; newuvs[i].y = p.z; } } }
//public override void Modify(ref Vector3[] sverts, ref Vector3[] verts) public override void Modify(MegaModifiers mc) { Vector2[] uvs = mc.GetSourceUvs(); Vector2[] newuvs = mc.GetDestUvs(); if (mat == null || twidth == 0.0f) { Init(); } if (uvs.Length > 0 && twidth > 0.0f) { //Debug.Log("twidth " + twidth); xtiles = twidth / TileWidth; ytiles = theight / TileHeight; tuvw = (float)TileWidth / (float)twidth; tuvh = (float)TileHeight / (float)theight; maxframe = xtiles * ytiles; Frame = Frame % maxframe; int x = Frame % xtiles; int y = Frame / xtiles; float su = (x * tuvw); float sv = (y * tuvh); for (int i = 0; i < uvs.Length; i++) { Vector2 uv = Vector2.Scale(uvs[i] + off, scale); if (flipy) { uv.y = 1.0f - uv.y; } if (flipx) { uv.x = 1.0f - uv.x; } uv.x = su + (tuvw * uv.x); uv.y = 1.0f - (sv + (tuvh * uv.y)); newuvs[i] = uv; } } }
//public override void Modify(ref Vector3[] sverts, ref Vector3[] verts) public override void Modify(MegaModifiers mc) { Vector2[] uvs = mc.GetSourceUvs(); Vector2[] newuvs = mc.GetDestUvs(); if ( mat == null || twidth == 0.0f ) Init(); if ( uvs.Length > 0 ) { //Debug.Log("twidth " + twidth); xtiles = twidth / TileWidth; ytiles = theight / TileHeight; tuvw = (float)TileWidth / (float)twidth; tuvh = (float)TileHeight / (float)theight; maxframe = xtiles * ytiles; Frame = Frame % maxframe; int x = Frame % xtiles; int y = Frame / xtiles; float su = (x * tuvw); float sv = (y * tuvh); for ( int i = 0; i < uvs.Length; i++ ) { Vector2 uv = Vector2.Scale(uvs[i] + off, scale); if ( flipy ) uv.y = 1.0f - uv.y; if ( flipx ) uv.x = 1.0f - uv.x; uv.x = su + (tuvw * uv.x); uv.y = 1.0f - (sv + (tuvh * uv.y)); newuvs[i] = uv; } } }