public z_AttributeLayout(z_MeshChannel channel, z_ComponentIndex index, Vector2 range, int mask) { this.channel = channel; this.index = index; this.range = range; this.mask = mask; }
/** * Apply the mesh channel attributes to the graphics mesh. */ public void ApplyMeshAttributes(z_MeshChannel channel = z_MeshChannel.All) { editMesh.ApplyAttributesToUnityMesh(_graphicsMesh, channel); if (usingVertexStreams) { _graphicsMesh.UploadMeshData(false); } }
/** * Apply the vertex attributes to a UnityEngine mesh (does not set triangles) */ public void ApplyAttributesToUnityMesh(Mesh m, z_MeshChannel attrib = z_MeshChannel.All) { // I guess the default value for attrib makes the compiler think that else is never // activated? #pragma warning disable 0162 if (attrib == z_MeshChannel.All) { m.vertices = vertices; m.normals = normals; m.colors32 = colors; m.tangents = tangents; m.SetUVs(0, uv0); m.SetUVs(1, uv1); m.SetUVs(2, uv2); m.SetUVs(3, uv3); } else { if ((attrib & z_MeshChannel.Position) > 0) { m.vertices = vertices; } if ((attrib & z_MeshChannel.Normal) > 0) { m.normals = normals; } if ((attrib & z_MeshChannel.Color) > 0) { m.colors32 = colors; } if ((attrib & z_MeshChannel.Tangent) > 0) { m.tangents = tangents; } if ((attrib & z_MeshChannel.UV0) > 0) { m.SetUVs(0, uv0); } if ((attrib & z_MeshChannel.UV2) > 0) { m.SetUVs(1, uv1); } if ((attrib & z_MeshChannel.UV3) > 0) { m.SetUVs(2, uv2); } if ((attrib & z_MeshChannel.UV4) > 0) { m.SetUVs(3, uv3); } } #pragma warning restore 0162 }
public static int UVChannelToIndex(z_MeshChannel channel) { if (channel == z_MeshChannel.UV0) { return(0); } else if (channel == z_MeshChannel.UV2) { return(1); } else if (channel == z_MeshChannel.UV3) { return(2); } else if (channel == z_MeshChannel.UV4) { return(3); } return(-1); }
public Vector4 this[z_MeshChannel channel] { get { return(GetVec4(map[channel])); } set { SetVec4(map[channel], value); } }
public z_AttributeLayout(z_MeshChannel channel, z_ComponentIndex index, Vector2 range, int mask, string targetProperty, Texture2D texture = null) : this(channel, index, range, mask) { this.propertyTarget = targetProperty; this.previewTexture = texture; }
public z_AttributeLayout(z_MeshChannel channel, z_ComponentIndex index) : this(channel, index, Vector2.up, DefaultMask) { }
public z_SplatSet(Mesh mesh, z_MeshChannel[] channelMap) { List<Vector4> uv0 = new List<Vector4>(), uv2 = new List<Vector4>(), uv3 = new List<Vector4>(), uv4 = new List<Vector4>(); mesh.GetUVs(0, uv0); mesh.GetUVs(1, uv2); mesh.GetUVs(2, uv3); mesh.GetUVs(3, uv4); Color32[] color = mesh.colors32; Vector4[] tangent = mesh.tangents; int vertexCount = mesh.vertexCount; int channelCount = channelMap.Length; this.channelMap = channelMap; this.weights = z_Util.Fill<z_SplatWeight>((index) => { return new z_SplatWeight(channelCount * 4); }, vertexCount); for(int n = 0; n < channelCount; n++) { int index = n * COMPONENTS_PER_ATTRIBUTE; switch(channelMap[n]) { case z_MeshChannel.UV0: { if(uv0 == null || uv0.Count != vertexCount) goto case z_MeshChannel.NULL; for(int i = 0; i < vertexCount; i++) this.weights[i].Set(index, uv0[i]); break; } case z_MeshChannel.UV2: { if(uv2 == null || uv2.Count != vertexCount) goto case z_MeshChannel.NULL; for(int i = 0; i < vertexCount; i++) this.weights[i].Set(index, uv2[i]); break; } case z_MeshChannel.UV3: { if(uv3 == null || uv3.Count != vertexCount) goto case z_MeshChannel.NULL; for(int i = 0; i < vertexCount; i++) this.weights[i].Set(index, uv3[i]); break; } case z_MeshChannel.UV4: { if(uv4 == null || uv4.Count != vertexCount) goto case z_MeshChannel.NULL; for(int i = 0; i < vertexCount; i++) this.weights[i].Set(index, uv4[i]); break; } case z_MeshChannel.COLOR: { if(color == null || color.Length != vertexCount) goto case z_MeshChannel.NULL; for(int i = 0; i < vertexCount; i++) this.weights[i].Set(index, color[i]); break; } case z_MeshChannel.TANGENT: { if(tangent == null || tangent.Length != vertexCount) goto case z_MeshChannel.NULL; for(int i = 0; i < vertexCount; i++) this.weights[i].Set(index, tangent[i]); break; } case z_MeshChannel.NULL: { for(int i = 0; i < vertexCount; i++) this.weights[i].Set(index, Color32_Black); break; } } } for(int i = 0; i < vertexCount; i++) this.weights[i].MakeNonZero(); }
public z_SplatSet(int vertexCount, z_MeshChannel[] channelMap) { this.weights = z_Util.Fill<z_SplatWeight>((index) => { return new z_SplatWeight(channelMap.Length * 4); }, vertexCount); this.channelMap = channelMap; }