Esempio n. 1
0
        public bool AddTrangle(TTrangle trangle)
        {
            CleanUp();

            if (TCameraTrangles.Contains(trangle))
            {
                return(false);
            }

            TCameraTrangles.Add(trangle);

            return(true);
        }
Esempio n. 2
0
        protected virtual void Update()
        {
            Profiler.BeginSample("TCamreraMesh");

            if (TCameraTrangles.Count < 1)
            {
                Profiler.EndSample();
                return;
            }

            CleanUp();

            if (Target == null)
            {
                Profiler.EndSample();
                return;
            }

            if (PerformanceOptimizationOn)
            {
                PerformanceOptimizationSetup();
            }

            if (CurrentTrangle != null)
            {
                if (IsTrangleValid(CurrentTrangle) && TrangleCheckAndProcess(CurrentTrangle))
                {
                    Profiler.EndSample();
                    return;
                }

                CurrentTrangle = null;
            }

            for (int i = 0; i < TCameraTrangles.Count; i++)
            {
                var tri = TCameraTrangles[i];

                if (IsTrangleValid(tri) && TrangleCheckAndProcess(tri))
                {
                    LastTrangle    = CurrentTrangle;
                    CurrentTrangle = tri;
                    break;
                }
            }
            Profiler.EndSample();
        }
Esempio n. 3
0
        protected bool IsTrangleValid(TTrangle tri)
        {
            if (tri == null)
            {
                return(false);
            }

            if (!tri.PowerOn)
            {
                return(false);
            }

            if (!tri.Valid())
            {
                return(false);
            }

            return(true);
        }
Esempio n. 4
0
        protected override bool TrangleCheckAndProcess(TTrangle tri)
        {
            var vertices = tri.Vertices.ToArray();

            float[] weight;
            if (TCameraUtility.IsInsideTrangle(vertices, Target.position, out weight))
            {
                if (PowerOn)
                {
                    if (CurrentTrangle != tri)
                    {
                        var etri = tri as TEventTrangle;
                        if (!etri.AnyRelationship(CurrentTrangle as TEventTrangle))
                        {
                            tri.OnEnterTrangle();
                        }
                    }
                }
                return(true);
            }

            return(false);
        }
Esempio n. 5
0
        protected override bool TrangleCheckAndProcess(TTrangle tri)
        {
            var vertices = tri.Vertices.ToArray();

            float[] weight;
            if (TCameraUtility.IsInsideTrangle(vertices, Target.position, out weight))
            {
                if (PowerOn)
                {
                    var tVertices   = tri.vertices;
                    var eulerAngles = (tVertices[0] as TCameraVertex).EularAngle * weight[0] +
                                      (tVertices[1] as TCameraVertex).EularAngle * weight[1] +
                                      (tVertices[2] as TCameraVertex).EularAngle * weight[2];

                    var pivotPosition = (tVertices[0] as TCameraVertex).PivotPosition * weight[0] +
                                        (tVertices[1] as TCameraVertex).PivotPosition * weight[1] +
                                        (tVertices[2] as TCameraVertex).PivotPosition * weight[2];

                    //Add Other args

                    if (OnPositionChanged != null)
                    {
                        OnPositionChanged.Invoke(eulerAngles, pivotPosition);
                    }
                    if (OnPositionChangedWithSplitArgs != null)
                    {
                        OnPositionChangedWithSplitArgs.Invoke(eulerAngles.x, eulerAngles.y, eulerAngles.z);
                    }
                    if (OnComplexEvent != null)
                    {
                        OnComplexEvent.Invoke(eulerAngles, pivotPosition, weight);
                    }
                }
                return(true);
            }
            return(false);
        }
Esempio n. 6
0
 protected abstract bool TrangleCheckAndProcess(TTrangle tri);
Esempio n. 7
0
 public static bool IsPositiveOrder(TTrangle tTrangle)
 {
     return(CalOrienttionSign(tTrangle.vertices) < 0);
 }