예제 #1
0
        static void RenderSelected(Lidar myTarget, GizmoType gizmoType)
        {
            var initialColor = Color.blue;
            var finalColor   = Color.red;

            for (int i = 0; i < myTarget.nbOfBeams; i++)
            {
                var beamAngle = myTarget.GetAngle(i);
                Handles.color = Color.Lerp(initialColor, finalColor,
                                           myTarget.nbOfBeams == 1 ? .5f : i / (float)(myTarget.nbOfBeams - 1));
                DrawArc(myTarget, beamAngle - .5f);
            }
        }
예제 #2
0
        static void DrawArc(Lidar src, float positionInOtherDimension)
        {
            var from = new Vector3(0,
                                   Mathf.Sin((src.verticalFieldOfView * positionInOtherDimension * Mathf.Deg2Rad)),
                                   Mathf.Cos(-(src.verticalFieldOfView * positionInOtherDimension * Mathf.Deg2Rad)));;

            from = Quaternion.Euler(0, -src.horizontalFieldOfView * .5f, 0) * from;

            Handles.DrawWireArc(src.transform.position,
                                src.transform.rotation * Vector3.up,
                                src.transform.rotation * from,
                                src.horizontalFieldOfView,
                                src.nearClipPlane);
            Handles.DrawWireArc(src.transform.position,
                                src.transform.rotation * Vector3.up,
                                src.transform.rotation * from,
                                src.horizontalFieldOfView,
                                src.farClipPlane);
        }