public void SetMask(Matrix4x4 matrix, Texture shape, P3dChannel channel, Vector3 stretch) { MaskMatrix = matrix; MaskShape = shape; MaskChannel = P3dHelper.IndexToVector((int)channel); MaskStretch = new Vector3(stretch.x * 2.0f, stretch.y * 2.0f, 2.0f); }
public static void ApplyStatic(P3dChannel channel) { cachedMaterial.SetMatrix(P3dShader._Matrix, cachedMatrix.inverse); cachedMaterial.SetVector(P3dShader._Direction, cachedDirection); cachedMaterial.SetColor(P3dShader._Color, cachedColor); cachedMaterial.SetFloat(P3dShader._Opacity, cachedOpacity); cachedMaterial.SetFloat(P3dShader._Hardness, cachedHardness); cachedMaterial.SetTexture(P3dShader._Texture, cachedTexture); cachedMaterial.SetTexture(P3dShader._Shape, cachedShape); cachedMaterial.SetFloat(P3dShader._NormalScale, cachedNormalScale); }
public void SetMaterial(P3dBlendMode blendMode, Texture texture, Texture shape, P3dChannel shapeChannel, float hardness, float wrapping, float normalBack, float normalFront, float normalFade, Color color, float opacity, Texture tileTexture, Matrix4x4 tileMatrix, float tileBlend) { switch (Extrusions) { case 0: Material = cachedSpotMaterials[blendMode]; break; case 1: Material = cachedLineMaterials[blendMode]; break; case 2: Material = cachedQuadMaterials[blendMode]; break; } Blend = blendMode; Color = color; Opacity = opacity; Hardness = hardness; Wrapping = wrapping; Texture = texture; Shape = shape; ShapeChannel = P3dHelper.IndexToVector((int)shapeChannel); TileTexture = tileTexture; TileMatrix = tileMatrix; TileBlend = tileBlend; var pointA = normalFront - 1.0f - normalFade; var pointB = normalFront - 1.0f; var pointC = 1.0f - normalBack + normalFade; var pointD = 1.0f - normalBack; NormalFront = new Vector2(pointA, P3dHelper.Reciprocal(pointB - pointA)); NormalBack = new Vector2(pointC, P3dHelper.Reciprocal(pointD - pointC)); }
/// <summary>This static method allows you to fix the seams of the source mesh at runtime.</summary> public static void Generate(Mesh source, ref Mesh output, P3dChannel channel, float threshold, float border) { if (source != null) { if (output == null) { output = new Mesh(); } currentOutput = output; currentSource = source; currentChannel = channel; currentBorder = border; areaThreshold = threshold * threshold; coordThreshold = threshold * threshold; output.Clear(false); insertions.Clear(); output.name = source.name + " (Fixed Seams)"; output.bindposes = source.bindposes; output.bounds = source.bounds; output.subMeshCount = source.subMeshCount; source.GetBoneWeights(boneWeights); source.GetColors(colors); source.GetNormals(normals); source.GetTangents(tangents); source.GetUVs(0, coords0); source.GetUVs(1, coords1); source.GetUVs(2, coords2); source.GetUVs(3, coords3); source.GetVertices(positions); DoGenerate(); output.boneWeights = boneWeights.ToArray(); output.SetColors(colors); output.SetNormals(normals); output.SetTangents(tangents); output.SetUVs(0, coords0); output.SetUVs(1, coords1); output.SetUVs(2, coords2); output.SetUVs(3, coords3); if (source.blendShapeCount > 0) { var tempDeltaVertices = new Vector3[source.vertexCount]; var tempDeltaNormals = new Vector3[source.vertexCount]; var tempDeltaTangents = new Vector3[source.vertexCount]; for (var i = 0; i < source.blendShapeCount; i++) { var shapeName = source.GetBlendShapeName(i); var frameCount = source.GetBlendShapeFrameCount(i); for (var j = 0; j < frameCount; j++) { source.GetBlendShapeFrameVertices(i, j, tempDeltaVertices, tempDeltaNormals, tempDeltaTangents); deltaVertices.Clear(); deltaNormals.Clear(); deltaTangents.Clear(); deltaVertices.AddRange(tempDeltaVertices); deltaNormals.AddRange(tempDeltaNormals); deltaTangents.AddRange(tempDeltaTangents); for (var k = 0; k < insertions.Count; k++) { var insertion = insertions[k]; deltaVertices.Add(deltaVertices[insertion]); deltaNormals.Add(deltaNormals[insertion]); deltaTangents.Add(deltaTangents[insertion]); } output.AddBlendShapeFrame(shapeName, source.GetBlendShapeFrameWeight(i, j), deltaVertices.ToArray(), deltaNormals.ToArray(), deltaTangents.ToArray()); } } } } }