public static async Task <IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req,
            ILogger log)
        {
            IActionResult output;
            var           trasnformed = default(string);
            var           mapper      = new SummaryDataMapper();

            log.LogInformation("Starting PID Summary Data ETL Job");
            log.LogInformation($"Request Size is {req.ContentLength}");

            try
            {
                string payload = Utiliy.ExtractRequestPayload(req);
                trasnformed = Utiliy.TransformPayload <SummaryRecord>(payload, mapper, log);
            }
            catch (ArgumentNullException exception)
            {
                log.LogError(exception.Message);
            }
            catch (ArgumentException exception)
            {
                log.LogError(exception.Message);
            }
            finally
            {
                output = trasnformed != string.Empty ?
                         (ActionResult) new OkObjectResult($"{trasnformed}")
                    : new BadRequestObjectResult("Transforming PID data failed.");
            }
            return(output);
        }
示例#2
0
    //
    // UPDATE (main refresh routine)
    //

    //sets the eyes to look at the target
    // target_point is the absolute point in space that we want to wantch at.
    public void UpdateEyesRotation(Vector3 leftEyePosition, Vector3 rightEyePosition,
                                   Quaternion leftEyeRotation, Quaternion rightEyeRotation,
                                   ref float[] outBlendShapeWeights,
                                   ref Quaternion inOutNeckRotation,
                                   float dt)
    {
        //
        // If the target is null, we reset all target angles to 0.
        float newEyesPitch = 0.0f;
        float newEyesYaw   = 0.0f;

        if (this.eyeGazeTargetPoint.HasValue)
        {
            Vector3 abs_target_point = this.eyeGazeTargetPoint.Value;

            //
            // Calculate the target in "eye-apose" space, i.e., relatively to the eye (or their midpoint) when the character stands in A-Pose.
            // It means that the target_point must be transformed as if it positioned relatively to the character standing in the default A-Pose.

            //
            // Decomposing the eye rotation matrix
            // The current rotation C can be decomposed in initial rotation I and an additional delta D in global space.
            //   C = D * I
            // (That is different from decomposing in initial plus local transform C = I * D_loc)
            // Hence,
            //   D = C * Iinv
            // In order to transform the absolute target in the original global space before rotation, we need the inverse of D.
            // In general (AB)inv = Binv * Ainv
            // Hence:
            //  Dinv = I * Cinv
            //


            //
            // This will be splitted in two when the two eyes will be driven independently.

            Vector3 eyeMidPoint = new Vector3(
                (leftEyePosition.x + rightEyePosition.x) / 2.0f,
                (leftEyePosition.y + rightEyePosition.y) / 2.0f,
                (leftEyePosition.z + rightEyePosition.z) / 2.0f
                );

#if DEBUG_GEOM
            Debug.DrawLine(leftEyePosition, rightEyePosition, Color.blue, 0.1f, false);
#endif

            Vector3 targetPointInvDelta = this.aPoseLeftEyeRotation * Quaternion.Inverse(leftEyeRotation) * abs_target_point;

            Vector3 eyeMidPointInvDelta = this.aPoseLeftEyeRotation * Quaternion.Inverse(leftEyeRotation) * eyeMidPoint;
            Vector3 targetPointEyeSpace = targetPointInvDelta - eyeMidPointInvDelta;


            // Calculate the targetPoint projected on the horizontal plane which passes through the eyesMidPoint
            float hproj_dist = targetPointEyeSpace.x * HORIZ_PLANE_NORMAL.x
                               + targetPointEyeSpace.y * HORIZ_PLANE_NORMAL.y
                               + targetPointEyeSpace.z * HORIZ_PLANE_NORMAL.z;
            Vector3 targetHplaneProjection = targetPointEyeSpace - (HORIZ_PLANE_NORMAL * hproj_dist);

#if DEBUG_GEOM
            Debug.DrawLine(Vector3.zero, targetPointEyeSpace, Color.red);
            Debug.DrawLine(Vector3.zero, targetHplaneProjection, Utiliy.darker(Color.red));
#endif


            //
            // Calculate the pitch: the vertical orientation of the eyes.

            // Calc the angle (in degrees) between the vector pointing to the target and its projection on the vertical plane
            float vertAngleBetween = Vector3.Angle(targetPointEyeSpace, targetHplaneProjection);
            newEyesPitch = Vector3.Dot(targetPointEyeSpace, HORIZ_PLANE_NORMAL) >= 0 ? vertAngleBetween : -vertAngleBetween;

            //
            // Calculate the yaw: the horizontal orientation of the eyes

            // Calc the angle (in degrees) between the forward vector the the target in eye-space.
            float horizAngleBetween = Vector3.Angle(this.aPoseFwdDirection, targetHplaneProjection);
            newEyesYaw = Vector3.Dot(targetHplaneProjection, this.aPoseRightDirection) <= 0 ? horizAngleBetween : -horizAngleBetween;
        }

        //
        // Increment the current eyes yaw/pitch according to eyes movement speed
        float deltaEyesPitch = newEyesPitch - this.eyesPitch;
        this.eyesPitch += LinearInc(deltaEyesPitch, this.eyesRotSpeed, dt);

        float deltaEyesYaw = newEyesYaw - this.eyesYaw;
        this.eyesYaw += LinearInc(deltaEyesYaw, this.eyesRotSpeed, dt);

#if DEBUG_GEOM
        {
            // Test, reproject the line of sight direction using the calculated angles
            // Vector3 rebuiltTarget = Quaternion.AngleAxis(-newEyesYaw, HORIZ_PLANE_NORMAL) * FORWARD;
            // WRONG!!! Vector3 rebuiltTarget = Quaternion.AngleAxis(-newEyesPitch, RIGHT) * Quaternion.AngleAxis(-newEyesYaw, HORIZ_PLANE_NORMAL) * FORWARD;
            //Vector3 rebuiltTarget = Quaternion.AngleAxis(-newEyesYaw, HORIZ_PLANE_NORMAL) * Quaternion.AngleAxis(-newEyesPitch, RIGHT) * FORWARD;
            Vector3 rebuiltTarget = Quaternion.AngleAxis(-newEyesYaw, HORIZ_PLANE_NORMAL) * Quaternion.AngleAxis(-newEyesPitch, this.aPoseRightDirection) * this.aPoseFwdDirection;
            Debug.DrawRay(Vector3.zero, rebuiltTarget, Color.green);
        }
#endif
        //
        // Activate the yaw/pitch rotations for the neck.
        if (enableNeckRotation)
        {
            float deltaPitch = 0.0f;
            if (this.eyesPitch > EYES_MAX_PITCH)
            {
                deltaPitch     = this.eyesPitch - EYES_MAX_PITCH;
                this.eyesPitch = EYES_MAX_PITCH;
            }
            else if (this.eyesPitch < -EYES_MAX_PITCH)
            {
                deltaPitch     = this.eyesPitch + EYES_MAX_PITCH;
                this.eyesPitch = -EYES_MAX_PITCH;
            }

            this.neckPitch += SmoothtInc(deltaPitch, neckRotTime, neckRotMaxSpeed, dt);
            this.neckPitch += SmoothtInc(-this.neckPitch, neckRotTime / neckRestTendencyStrenght, neckRotMaxSpeed * neckRestTendencyStrenght, dt);

            if (this.neckPitch > NECK_MAX_PITCH)
            {
                this.neckPitch = NECK_MAX_PITCH;
            }
            else if (neckPitch < NECK_MIN_PITCH)
            {
                this.neckPitch = NECK_MIN_PITCH;
            }

            // Debug.Log("Delta pitch/Neck pitch: "+deltaPitch+"\t"+neckPitch) ;


            float deltaYaw = 0.0f;
            if (this.eyesYaw >= EYES_MAX_YAW)
            {
                deltaYaw     = this.eyesYaw - EYES_MAX_YAW;
                this.eyesYaw = EYES_MAX_YAW;
            }
            else if (this.eyesYaw <= -EYES_MAX_YAW)
            {
                deltaYaw     = this.eyesYaw + EYES_MAX_YAW;
                this.eyesYaw = -EYES_MAX_YAW;
            }

            this.neckYaw += SmoothtInc(deltaYaw, neckRotTime, neckRotMaxSpeed, dt);
            this.neckYaw += SmoothtInc(-this.neckYaw, neckRotTime / neckRestTendencyStrenght, neckRotMaxSpeed * neckRestTendencyStrenght, dt);

            if (neckYaw > NECK_MAX_YAW)
            {
                this.neckYaw = NECK_MAX_YAW;
            }
            else if (neckYaw < NECK_MIN_YAW)
            {
                this.neckYaw = NECK_MIN_YAW;
            }

            // Debug.Log("Delta yaw/Neck yaw: "+deltaYaw+"\t"+neckYaw) ;

#if DEBUG_GEOM
            {
                float totalYaw   = this.neckYaw + this.eyesYaw;
                float totalPitch = this.neckPitch + this.eyesPitch;
                // Test, reproject the line of sight direction using the calculated angles
                Vector3 rebuiltTarget = Quaternion.AngleAxis(-totalYaw, HORIZ_PLANE_NORMAL) * Quaternion.AngleAxis(-totalPitch, this.aPoseRightDirection) * this.aPoseFwdDirection;
                Debug.DrawRay(Vector3.zero, rebuiltTarget, Color.white);
            }
#endif

            //
            // Computer the new quaternion for the Neck.

            // G = P * L --> P = G * L^-1
            Quaternion neckAPoseParentRotation = this.aPoseNeckRotation * Quaternion.Inverse(this.aPoseNeckLocalRotation);

            // I have to compute the quaternion representing the rotation of the two angles.
            // yaw * pitch * oroginal pose
            Quaternion neckRotQuat = Quaternion.AngleAxis(-this.neckYaw, HORIZ_PLANE_NORMAL) * Quaternion.AngleAxis(-this.neckPitch, this.aPoseRightDirection);
            // this rotation must be applied to a rotation describing the neck straight in the current charactr orientation.

            // Test left/right
            // Quaternion neckLocalRotQuat = Quaternion.Inverse(neckAPoseParentRotation) * Quaternion.AngleAxis(45, HORIZ_PLANE_NORMAL) * neckAPoseParentRotation;
            // Test up/down
            // Quaternion neckLocalRotQuat = Quaternion.Inverse(neckAPoseParentRotation) * Quaternion.AngleAxis(45, this.aPoseRightDirection) * neckAPoseParentRotation;

            Quaternion neckLocalRotQuat = Quaternion.Inverse(neckAPoseParentRotation) * neckRotQuat * neckAPoseParentRotation;

            //Debug.Log("aposenecklocalrot=" + this.aPoseNeckLocalRotation);
            inOutNeckRotation = neckLocalRotQuat * this.aPoseNeckLocalRotation;
        }


        //
        // Calculate the proportion from the pitch angle to BlendShape percentage
        // weightEyesPitch : 50% = pitch : 45deg
        float weightEyesPitch = 0.5f * this.eyesPitch / 45.0f;

        // Calculate the proportion from the yaw angle to the BlendShape percentage
        // weightEyesYaw : 50% = yaw : 52deg
        float weightEyesYaw = 0.5f * this.eyesYaw / 52.0f;

        //Debug.Log("weightEyesDown: " + weightEyesPitch + " weightEyesLeft: " + weightEyesYaw);

        //Blendshapes are registered int the DefaultExecutionOrder: EYES_RIGHT, EYES_LEFT, EYES_DOWN, EYES_UP
        if (weightEyesPitch >= 0.0f)
        {
            outBlendShapeWeights[3] = weightEyesPitch;
            outBlendShapeWeights[2] = 0.0f;
        }
        else
        {
            outBlendShapeWeights[2] = -weightEyesPitch;
            outBlendShapeWeights[3] = 0.0f;
        }

        if (weightEyesYaw >= 0.0f)
        {
            outBlendShapeWeights[0] = weightEyesYaw;
            outBlendShapeWeights[1] = 0.0f;
        }
        else
        {
            outBlendShapeWeights[1] = -weightEyesYaw;
            outBlendShapeWeights[0] = 0.0f;
        }
    }     // end update
示例#3
0
文件: Game.cs 项目: GokitaU/DIYFE
        public bool UpdateGame()
        {
            if (this.GameId != 0)
            {
                string queryString = "UPDATE [dbo].[Game] "
                                     + "SET [GameStatusTypeId] = @GameStatusTypeId "
                                     + " ,[HomeTeamScore] = @HomeTeamScore"
                                     + " ,[AwayTeamScore] = @AwayTeamScore"
                                     + " ,[WinningTeamId] = @WinningTeamId"
                                     + " WHERE GameId = @GameId";

                using (SqlConnection connection = new SqlConnection(Base.conn))
                {
                    // Create the Command and Parameter objects.
                    SqlCommand command = new SqlCommand(queryString, connection);
                    command.Parameters.AddWithValue("@GameId", this.GameId);
                    //command.Parameters.AddWithValue("@GameDate", this.GameDate);
                    command.Parameters.AddWithValue("@GameStatusTypeId", this.GameStatusTypeId);
                    command.Parameters.AddWithValue("@HomeTeamScore", this.HomeTeamScore);
                    command.Parameters.AddWithValue("@AwayTeamScore", this.AwayTeamScore);
                    command.Parameters.AddWithValue("@WinningTeamId", this.WinningTeamId);

                    try
                    {
                        connection.Open();
                        command.ExecuteNonQuery();
                    }
                    catch (Exception ex)
                    {
                        SportsError sError = new SportsError(ex, this.GameId);
                    }
                }


                Utiliy u   = new Utiliy();
                Bet    bet = u.CheckGameBet(this.GameId);
                if (bet.BetId != 0)
                {
                    //This is a own bet
                    if (bet.WinningBetTeamId == this.WinningTeamId)
                    {
                        if (this.GameDate == bet.BetADate)
                        {
                            bet.WinningBet = "A";
                        }
                        if (this.GameDate == bet.BetBDate)
                        {
                            bet.WinningBet = "B";
                        }
                        if (this.GameDate == bet.BetCDate)
                        {
                            bet.WinningBet = "C";
                        }
                        if (this.GameDate == bet.BetDDate)
                        {
                            bet.WinningBet = "D";
                        }

                        bet.TempUpdateBet();
                    }
                }
            }
            return(true);
        }