コード例 #1
0
        public GameObject CreateCamera(TileNode loc, FramingType scale, Orient orient, Hangle hangle, Vangle vangle)
        {
            //Debug.Log(scale);
            GameObject camHost = new GameObject();
            //camHost.transform.position = loc.transform.position;
            var cva           = camHost.AddComponent <CinemachineVirtualCamera>();
            var cbod          = camHost.AddComponent <CinemachineCameraBody>();
            var cc            = cva.AddCinemachineComponent <CinemachineComposer>();
            var cbmcp         = cva.AddCinemachineComponent <CinemachineBasicMultiChannelPerlin>();
            var camattributes = camHost.AddComponent <CamAttributesStruct>();

            camattributes.Set(scale, loc.transform.gameObject.name, orient, hangle, vangle);

            // composer parameters TODO: tweak via separate gameobject component structure
            cc.m_HorizontalDamping = 10;
            cc.m_VerticalDamping   = 10;
            cc.m_LookaheadTime     = 0.2f;
            cc.m_DeadZoneWidth     = 0.25f;
            cc.m_SoftZoneWidth     = 0.5f;

            var framing_data = FramingParameters.FramingTable[scale];

            // FStop
            cbod.IndexOfFStop = CinematographyAttributes.fStops[framing_data.DefaultFStop];
            // Lens
            cbod.IndexOfLens = CinematographyAttributes.lenses[framing_data.DefaultFocalLength];

            // set at planning time.
            //cbod.FocusTransform = target_go.transform;

            // create small amount of noise
            cbmcp = cva.AddCinemachineComponent <CinemachineBasicMultiChannelPerlin>();
            cbmcp.m_NoiseProfile  = CinematographyAttributes.standardNoise;
            cbmcp.m_AmplitudeGain = 0.5f;
            cbmcp.m_FrequencyGain = 1f;

            // worldDirectionOf Camera relative to location transform
            var camTransformDirection = DegToVector3(camattributes.OrientInt + camattributes.HangleInt);

            // calculate where to put camera
            var fakeTarget = CreateFakeTarget(actors[0].gameObject, loc.transform);
            var camDist    = CinematographyAttributes.CalcCameraDistance(fakeTarget, scale);

            GameObject.DestroyImmediate(fakeTarget);
            cbod.FocusDistance = camDist;

            // Calculate Camera Position
            camHost.transform.position = loc.transform.position + camTransformDirection * camDist;
            var height = CinematographyAttributes.SolveForY(loc.transform.position, camHost.transform.position, 0.5f, camattributes.VangleInt);

            camHost.transform.position = new Vector3(camHost.transform.position.x, height, camHost.transform.position.z);

            // Gives starting orientation of camera. At planning time, a "lookAt" parameter is set to specific target.
            camHost.transform.rotation.SetLookRotation(loc.transform.position);

            // Set Name of camera object
            camHost.name = string.Format("{0}.{1}.{2}.{3}.{4}", loc.name, scale, camattributes.targetOrientation, camattributes.hangle, camattributes.vangle);
            return(camHost);
        }
コード例 #2
0
ファイル: CamSchema.cs プロジェクト: drwiner/UnityAI4Games
 public CamSchema(FramingType _scale, string _tLoc, Orient _tOrient, Hangle _hangle, Vangle _vangle)
 {
     scale             = _scale;
     targetLocation    = _tLoc;
     targetOrientation = _tOrient;
     hangle            = _hangle;
     vangle            = _vangle;
 }
コード例 #3
0
ファイル: CamSchema.cs プロジェクト: drwiner/GDPOPS
 public CamSchema(FramingType _scale, string _tLoc, Orient _tOrient, Hangle _hangle, Vangle _vangle, float _distance, float _height)
 {
     scale             = _scale;
     targetLocation    = _tLoc;
     targetOrientation = _tOrient;
     hangle            = _hangle;
     vangle            = _vangle;
     distance          = _distance;
     height            = _height;
 }
コード例 #4
0
        public void CreateFrameType(JSONNode json)
        {
            var ft = json["scale"].Value;

            if (Enum.IsDefined(typeof(FramingType), ft))
            {
                // cast var as FramingType
                frame_type = (FramingType)Enum.Parse(typeof(FramingType), ft);
            }

            framing_data = FramingParameters.FramingTable[frame_type];
        }
コード例 #5
0
        public async Task Should_use_non_transparent_framing(FramingType framingType, byte[] expectedSuffix)
        {
            var framer = new MessageFramer(framingType);

            using (var ms = new MemoryStream())
            {
                await framer.WriteFrame(this.message, ms);

                var data = ms.ToArray();
                data.EndsWith(expectedSuffix).ShouldBeTrue();
            }
        }
コード例 #6
0
        public static float CalcCameraDistance(GameObject framingTarget, FramingType ft)
        {
            // pick out the framing parameters from the table
            FramingParameters framingParameters = FramingParameters.FramingTable[ft];

            // get the apprpriate lens based on the focal length for the framing parameters
            ushort?tempLensIndex = lenses[framingParameters.DefaultFocalLength];

            // calculate the area of the target
            Bounds targetBounds = framingTarget.GetComponent <BoxCollider>().bounds;

            // calculate the vertical field of view
            float vFov = lensFovData[tempLensIndex.Value]._unityVFOV * Mathf.Deg2Rad;

            float frustumHeight = (1 / framingParameters.TargetPercent) * (targetBounds.max.y - targetBounds.min.y);

            float distanceToCamera = frustumHeight / Mathf.Tan(vFov / 2);

            return(distanceToCamera);
        }
コード例 #7
0
        /// <summary>
        /// Adds a sink that writes log events to a TCP syslog server, optionally over a TLS-secured
        /// </summary>
        /// <param name="loggerSinkConfig">The logger configuration</param>
        /// <param name="host">Hostname of the syslog server</param>
        /// <param name="port">Port the syslog server is listening on</param>
        /// <param name="appName">The name of the application. Defaults to the current process name</param>
        /// <param name="framingType">How to frame/delimit syslog messages for the wire</param>
        /// <param name="format">The syslog message format to be used</param>
        /// <param name="facility">The category of the application</param>
        /// <param name="secureProtocols">
        /// SSL/TLS protocols to be used for a secure channel. Set to None for an unsecured connection
        /// </param>
        /// <param name="certProvider">Optionally used to present the syslog server with a client certificate</param>
        /// <param name="certValidationCallback">
        /// Optional callback used to validate the syslog server's certificate. If null, the system default
        /// will be used
        /// </param>
        /// <param name="outputTemplate">A message template describing the output messages
        /// <seealso cref="https://github.com/serilog/serilog/wiki/Formatting-Output"/>
        /// </param>
        public static LoggerConfiguration TcpSyslog(this LoggerSinkConfiguration loggerSinkConfig,
                                                    string host, int port        = 1468, string appName = null, FramingType framingType = FramingType.OCTET_COUNTING,
                                                    SyslogFormat format          = SyslogFormat.RFC5424, Facility facility = Facility.Local0,
                                                    SslProtocols secureProtocols = SslProtocols.Tls12, ICertificateProvider certProvider = null,
                                                    RemoteCertificateValidationCallback certValidationCallback = null,
                                                    string outputTemplate = null)
        {
            var formatter = GetFormatter(format, appName, facility, outputTemplate);

            var config = new SyslogTcpConfig
            {
                Host                   = host,
                Port                   = port,
                Formatter              = formatter,
                Framer                 = new MessageFramer(framingType),
                SecureProtocols        = secureProtocols,
                CertProvider           = certProvider,
                CertValidationCallback = certValidationCallback
            };

            return(TcpSyslog(loggerSinkConfig, config));
        }
コード例 #8
0
 public override string ToString()
 {
     return(string.Format("({0},{1})", FramingTarget, FramingType.ToString()));
 }
コード例 #9
0
 public MessageFramer(FramingType framingType, Encoding encoding = null)
 {
     this.framingType = framingType;
     this.encoding    = encoding ?? Encoding.UTF8;
 }