// Update is called once per frame void Update() { Control(); Vector2 tOffset = new Vector3(Mathf.Cos(tTime), Mathf.Sin(tTime)); mMF.mesh.Clear(); //Clear buffers mVertices[0] = V1 * Scale; //Reset vertex positions mVertices[1] = V2 * Scale; mVertices[2] = V3 * Scale; mVertices[3] = V4 * Scale; mMF.mesh.vertices = mVertices; mNormals[0] = Quaternion.AngleAxis(AngleX, mRotationAxisX) * Quaternion.AngleAxis(-AngleY, mRotationAxisY) * tNormal; //Vertext normals, they change how light is affected mNormals[1] = Quaternion.AngleAxis(AngleX, mRotationAxisX) * Quaternion.AngleAxis(AngleY, mRotationAxisY) * tNormal; mNormals[2] = Quaternion.AngleAxis(-AngleX, mRotationAxisX) * Quaternion.AngleAxis(-AngleY, mRotationAxisY) * tNormal; mNormals[3] = Quaternion.AngleAxis(-AngleX, mRotationAxisX) * Quaternion.AngleAxis(AngleY, mRotationAxisY) * tNormal; mMF.mesh.normals = mNormals; mUVs[0] = new Vector2(0, 0) + tOffset; //Mesh UV maps 2D texture to mesh mUVs[1] = new Vector2(MapX, 0) + tOffset; mUVs[2] = new Vector2(0, MapY) + tOffset; mUVs[3] = new Vector2(MapX, MapY) + tOffset; mMF.mesh.uv = mUVs; mMF.mesh.triangles = mTriangles; MeshDebug.DebugDrawVertexNormals(transform.position, transform.rotation, mMF.mesh, Color.red); MeshDebug.DebugDrawTriangleNormals(transform.position, transform.rotation, mMF.mesh, Color.green); tTime += Time.deltaTime * Speed; }
public void Update() { if (mMF != null) { if (VertexNormals) { MeshDebug.DebugDrawVertexNormals(transform.position, transform.rotation, mMF.mesh, Color.red); } if (TriNormals) { MeshDebug.DebugDrawTriangleNormals(transform.position, transform.rotation, mMF.mesh, Color.green); } } else { mMF = GetComponent <MeshFilter>(); } }