public void HandleHitCoord(bool preview, int priority, float pressure, int seed, P3dHit hit, Quaternion rotation) { var model = hit.Root.GetComponentInParent <P3dModel>(); if (model != null) { var paintableTextures = P3dPaintableTexture.FilterAll(model, group); if (paintableTextures.Count > 0) { var finalColor = color; var finalOpacity = opacity; var finalTexture = texture; if (modifiers != null && modifiers.Count > 0) { P3dHelper.BeginSeed(seed); modifiers.ModifyColor(ref finalColor, preview, pressure); modifiers.ModifyOpacity(ref finalOpacity, preview, pressure); modifiers.ModifyTexture(ref finalTexture, preview, pressure); P3dHelper.EndSeed(); } P3dCommandFill.Instance.SetState(preview, priority); P3dCommandFill.Instance.SetMaterial(blendMode, finalTexture, finalColor, opacity, minimum); for (var i = paintableTextures.Count - 1; i >= 0; i--) { var paintableTexture = paintableTextures[i]; P3dPaintableManager.Submit(P3dCommandFill.Instance, model, paintableTexture); } } } }
public void HandleHitPoint(List <P3dCommand> commands, List <P3dTransform> repeaters, bool preview, Collider collider, Vector3 worldPosition, Quaternion worldRotation, float pressure) { if (collider != null) { var model = collider.GetComponent <P3dModel>(); if (model != null) { var paintableTextures = P3dPaintableTexture.Filter(model, groups); if (paintableTextures.Count > 0) { var finalColor = color; var finalOpacity = opacity; var finalTexture = texture; P3dPaintableManager.BuildModifiers(gameObject); P3dPaintableManager.ModifyColor(ref finalColor); P3dPaintableManager.ModifyOpacity(ref finalOpacity); P3dPaintableManager.ModifyTexture(ref finalTexture); Command.Instance.SetMaterial(blendMode, finalTexture, finalColor, opacity); for (var i = paintableTextures.Count - 1; i >= 0; i--) { var paintableTexture = paintableTextures[i]; P3dPaintableManager.Submit(Command.Instance, model, paintableTexture, preview); } } } } }
public void HandleHitRaycast(bool preview, int priority, float pressure, int seed, RaycastHit hit, Quaternion rotation) { var model = hit.collider.GetComponentInParent <P3dModel>(); if (model != null) { var paintableTextures = P3dPaintableTexture.Filter(model, group); if (paintableTextures.Count > 0) { var finalColor = color; var finalTexture = texture; if (modifiers != null && modifiers.Count > 0) { P3dHelper.BeginSeed(seed); modifiers.ModifyColor(ref finalColor, preview, pressure); modifiers.ModifyTexture(ref finalTexture, preview, pressure); P3dHelper.EndSeed(); } P3dCommandReplace.Instance.SetState(preview, priority); P3dCommandReplace.Instance.SetMaterial(finalTexture, finalColor); for (var i = paintableTextures.Count - 1; i >= 0; i--) { var paintableTexture = paintableTextures[i]; P3dPaintableManager.Submit(P3dCommandReplace.Instance, model, paintableTexture); } } } }
public void HandleHitPoint(bool preview, int priority, Collider collider, Vector3 worldPosition, Quaternion worldRotation, float pressure) { if (collider != null) { var model = collider.GetComponent <P3dModel>(); if (model != null) { var paintableTextures = P3dPaintableTexture.Filter(model, group); if (paintableTextures.Count > 0) { var finalColor = color; var finalTexture = texture; P3dPaintableManager.BuildModifiers(gameObject); P3dPaintableManager.ModifyColor(pressure, ref finalColor); P3dPaintableManager.ModifyTexture(pressure, ref finalTexture); Command.Instance.SetState(preview, priority); Command.Instance.SetMaterial(finalTexture, finalColor); for (var i = paintableTextures.Count - 1; i >= 0; i--) { var paintableTexture = paintableTextures[i]; P3dPaintableManager.Submit(Command.Instance, model, paintableTexture); } } } } }
public void HandleHitPoint(bool preview, int priority, Collider collider, Vector3 worldPosition, Quaternion worldRotation, float pressure) { if (collider != null) { var model = collider.GetComponent <P3dModel>(); if (model != null) { var paintableTextures = P3dPaintableTexture.Filter(model, group); if (paintableTextures.Count > 0) { Command.Instance.SetState(preview, priority); Command.Instance.SetMaterial(textureR, textureG, textureB, textureA, channelR, channelG, channelB, channelA); for (var i = paintableTextures.Count - 1; i >= 0; i--) { var paintableTexture = paintableTextures[i]; P3dPaintableManager.Submit(Command.Instance, model, paintableTexture); } } } } }
public void HandleHitRaycast(bool preview, int priority, RaycastHit hit, float pressure) { var model = hit.collider.GetComponent <P3dModel>(); if (model != null) { var paintableTextures = P3dPaintableTexture.Filter(model, group); var finalOpacity = opacity + (1.0f - opacity) * opacityPressure * pressure; var finalRadius = radius + radiusPressure * pressure; var finalColor = color; var finalAngle = angle; var finalTexture = texture; P3dPaintableManager.BuildModifiers(gameObject); P3dPaintableManager.ModifyColor(pressure, ref finalColor); P3dPaintableManager.ModifyAngle(pressure, ref finalAngle); P3dPaintableManager.ModifyOpacity(pressure, ref finalOpacity); P3dPaintableManager.ModifyRadius(pressure, ref finalRadius); P3dPaintableManager.ModifyTexture(pressure, ref finalTexture); Command.Instance.SetMaterial(blendMode, finalTexture, finalColor, finalOpacity, shape); for (var i = paintableTextures.Count - 1; i >= 0; i--) { var paintableTexture = paintableTextures[i]; var coord = default(Vector2); switch (paintableTexture.Channel) { case P3dCoord.First: { coord = hit.textureCoord; } break; case P3dCoord.Second: { coord = hit.textureCoord2; } break; } Command.Instance.SetState(preview, priority); Command.Instance.SetLocation(paintableTexture.Current, coord, finalAngle, scale, finalRadius, texture); P3dPaintableManager.Submit(Command.Instance, model, paintableTexture); } } }
/// <summary>This method paints the scene using the current component settings at the specified <b>RaycastHit</b>. /// NOTE: The <b>rotation</b> argument is in world space, where <b>Quaternion.identity</b> means the paint faces forward on the +Z axis, and up is +Y.</summary> public void HandleHitRaycast(bool preview, int priority, float pressure, int seed, RaycastHit hit, Quaternion rotation) { if (paint == PaintType.In3D) { return; } var model = hit.collider.GetComponent <P3dModel>(); if (model != null) { var paintableTextures = P3dPaintableTexture.Filter(model, group); for (var i = paintableTextures.Count - 1; i >= 0; i--) { var paintableTexture = paintableTextures[i]; var coord = paintableTexture.GetCoord(ref hit); if (modifiers != null && modifiers.Count > 0) { var position = (Vector3)coord; P3dHelper.BeginSeed(seed); modifiers.ModifyPosition(ref position, preview, pressure); P3dHelper.EndSeed(); coord = position; } P3dCommandDecal.Instance.SetState(preview, priority); P3dCommandDecal.Instance.SetLocation(coord, false); HandleHitCommon(preview, pressure, seed, rotation); P3dCommandDecal.Instance.ApplyAspect(paintableTexture.Current); P3dPaintableManager.Submit(P3dCommandDecal.Instance, model, paintableTexture); } } }
public void HandleHitCoord(bool preview, int priority, float pressure, int seed, P3dHit hit, Quaternion rotation) { var model = hit.Root.GetComponentInParent <P3dModel>(); if (model != null) { var paintableTextures = P3dPaintableTexture.FilterAll(model, group); if (paintableTextures.Count > 0) { P3dCommandReplaceChannels.Instance.SetState(preview, priority); P3dCommandReplaceChannels.Instance.SetMaterial(textureR, textureG, textureB, textureA, channelR, channelG, channelB, channelA); for (var i = paintableTextures.Count - 1; i >= 0; i--) { var paintableTexture = paintableTextures[i]; P3dPaintableManager.Submit(P3dCommandReplaceChannels.Instance, model, paintableTexture); } } } }
protected virtual void Update() { if (paintableTexture != null && paintableTexture.Activated == true) { if (speed > 0.0f) { counter += speed * Time.deltaTime; } if (counter >= threshold) { var step = Mathf.FloorToInt(counter * 255.0f); if (step > 0) { var change = step / 255.0f; counter -= change; P3dCommandFill.Instance.SetState(false, 0); P3dCommandFill.Instance.SetMaterial(blendMode, texture, color, Mathf.Min(change, 1.0f), Mathf.Min(change, 1.0f)); var command = P3dPaintableManager.Submit(P3dCommandFill.Instance, paintableTexture.Paintable, paintableTexture); if (maskPaintableTexture != null) { command.LocalMaskTexture = maskPaintableTexture.Current; command.LocalMaskChannel = P3dHelper.IndexToVector((int)maskChannel); } else if (maskTexture != null) { command.LocalMaskTexture = maskTexture; command.LocalMaskChannel = P3dHelper.IndexToVector((int)maskChannel); } } } } }