Tanoda
PaintTest.cs
Go to the documentation of this file.
1using System;
2using System.Collections;
3using System.Collections.Generic;
4using Es.InkPainter;
5using GILES;
6using UnityEngine;
8
9public class PaintTest : MonoBehaviour
10{
11 public GameObject ring;
12 public List<GameObject> paintableObjects;
13
14 [SerializeField]
15 private Brush brush = null;
16
17 public Vector3 planeNormals;
18
19 void Update()
20 {
21 Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
22 GameObject go = pb_HandleUtility.ObjectRaycast(ray, paintableObjects, out var hit);
23 if (go)
24 {
25 ring.transform.position = go.transform.TransformPoint(hit.point);
26 var planeHelper = Math.GetNearestVerticesTriangle(hit.point, go.GetComponent<MeshFilter>().sharedMesh.vertices,
27 go.GetComponent<MeshFilter>().sharedMesh.triangles);
28
29 Debug.DrawLine(go.transform.TransformPoint(planeHelper[0]), go.transform.TransformPoint(planeHelper[1]), Color.magenta);
30 Debug.DrawLine(go.transform.TransformPoint(planeHelper[1]), go.transform.TransformPoint(planeHelper[2]), Color.magenta);
31 Debug.DrawLine(go.transform.TransformPoint(planeHelper[0]), go.transform.TransformPoint(planeHelper[2]), Color.magenta);
32
33 var plane = new Plane(planeHelper[0], planeHelper[1], planeHelper[2]);
34 planeNormals = plane.normal;
35 ring.transform.up = planeNormals;
36
37 var canvas = go.GetComponent<InkCanvas>();
38 if (canvas != null && canvas.Paint(brush, hit.point))
39 Debug.Log("painting :)");
40 }
41 }
42}
Es.InkPainter.Math Math
Definition: PaintTest.cs:7
UnityEngine.Debug Debug
Definition: TanodaServer.cs:19
UnityEngine.Color Color
Definition: TestScript.cs:32
Class managing brush information.
Definition: Brush.cs:11
Texture paint to canvas. To set the per-material.
Definition: InkCanvas.cs:23
static GameObject ObjectRaycast(Ray ray, IEnumerable< GameObject > objects, bool ignoreSelection=false)
GameObject ring
Definition: PaintTest.cs:11
Vector3 planeNormals
Definition: PaintTest.cs:17
List< GameObject > paintableObjects
Definition: PaintTest.cs:12
Definition: ClipPainter.cs:5