Exemple #1
0
        void Update()
        {
            Light l = fromObject.GetComponent <Light> ();

            if (l != null)
            {
                this.color = l.color;
            }

            Matrix4x4 lineMat = directionObject.transform.worldToLocalMatrix;

            this.LightLine = GetShadingLine();

            Vector3 fromPoint = lineMat.MultiplyVector(LightLine.Points[0].Position);
            Vector3 toPoint   = lineMat.MultiplyVector(LightLine.Points[1].Position);

            if (this.directionObject != null)
            {
                ShadingLine line = new ShadingLine();
                line.Add(new ShadingLinePoint(fromPoint, color));
                line.Add(new ShadingLinePoint(toPoint, color));
                ShadingLineController shadingLineController = directionObject.GetComponent <ShadingLineController>();
                shadingLineController.Initialize(line);
            }
        }
Exemple #2
0
        private void InitializeSpecular(IList <ShadingLine> lines)
        {
            Transform parent = specularOffset.transform;

            if (this.specularLineObjects.Count != lines.Count)
            {
                foreach (GameObject lineGo in this.specularLineObjects)
                {
                    Destroy(lineGo);
                }
                this.specularLineObjects.Clear();
                foreach (ShadingLine line in lines)
                {
                    GameObject go = Instantiate(prefabLineObject) as GameObject;
                    if (go != null)
                    {
                        Transform t = go.transform;
                        t.parent        = parent;
                        t.localPosition = new Vector3(0.0f, 0.0f, 0.0f);
                        t.localScale    = new Vector3(1.0f, 1.0f, 1.0f);
                        this.specularLineObjects.Add(go);
                    }
                }
            }

            for (int i = 0; i < this.specularLineObjects.Count; i++)
            {
                GameObject go = this.specularLineObjects[i];
                if (go != null)
                {
                    ShadingLineController shadingSpecularLineController = go.GetComponent <ShadingLineController> ();
                    shadingSpecularLineController.Initialize(lines[i]);
                }
            }
        }