Esempio n. 1
0
            public void Execute(ref FaceCameraComponent face, ref Translation position, ref Rotation rotation)
            {
                quaternion targetRotation = math.mul(quaternion.EulerXYZ(new float3(0, math.PI * 2, 0)).value, (cameraRotation));

                rotation.Value = QuaternionHelpers.slerpSafe(rotation.Value, targetRotation, delta * 3);
                //rotation.Value = quaternion.LookRotation(face.position - cameraPosition, new float3(0, 1, 0));
            }
Esempio n. 2
0
        public void SetRotation(float3 cameraPosition, quaternion cameraRotation, ref Rotation rotation, float delta)
        {
            quaternion targetRotation = math.mul(quaternion.EulerXYZ(new float3(0, math.PI * 2, 0)).value, (cameraRotation));

            if (delta > 1)
            {
                delta = 1;
            }
            rotation.Value = QuaternionHelpers.slerpSafe(rotation.Value, targetRotation, delta);
        }
Esempio n. 3
0
 public void Execute(ref Mover mover, ref BodyTorque bodyTorque, ref Translation position, ref Rotation rotation)    // ref AIState brain, ,
 {
     if (mover.disabled == 0)
     {
         float3     normalBetween = math.normalizesafe(mover.target - position.Value);
         quaternion targetAngle   = quaternion.LookRotationSafe(0.05f * normalBetween, math.up());
         quaternion newAngle      = QuaternionHelpers.slerp(rotation.Value, targetAngle, delta);
         Quaternion newAngle2     = new Quaternion(newAngle.value.x, newAngle.value.y, newAngle.value.z, newAngle.value.w);
         rotation.Value = (newAngle2);
     }
 }
Esempio n. 4
0
            public void Execute(ref FollowerCamera camera, ref Translation position, ref Rotation rotation)
            {
                /*if (camera.isMovement == 1)
                 * {
                 *  camera.targetPosition.x += camera.movement.x * delta * 4f;
                 *  camera.targetPosition.z += camera.movement.z * delta * 4f;
                 *  camera.targetPosition.y -= camera.movement.y * delta * 3f;
                 * }*/
                float3 newPosition = camera.Value.targetPosition;

                newPosition.x  = math.max(newPosition.x, -999);
                newPosition.x  = math.min(newPosition.x, 999);
                newPosition.y  = math.max(newPosition.y, -999);
                newPosition.y  = math.min(newPosition.y, 999);
                newPosition.z  = math.max(newPosition.z, -999);
                newPosition.z  = math.min(newPosition.z, 999);
                position.Value = math.lerp(position.Value, newPosition, delta * camera.Value.lerpSpeed.x);
                //position.Value = newPosition;
                rotation.Value = QuaternionHelpers.slerpSafe(rotation.Value.value, camera.Value.targetRotation.value, delta * camera.Value.lerpSpeed.y);//TurretAimSystem.le math.lerp(rotation.Value.value, slimeCamera.targetRotation.value, deltaTime * slimeCamera.lerpRotationSpeed);
            }
Esempio n. 5
0
 public void Execute(ref Aimer aimer, ref Shooter shooter, ref Targeter targeter, ref Translation position, ref Rotation rotation)
 {
     if (targeter.hasTarget == 1)
     {
         float3 positionValue  = position.Value;
         float3 targetPosition = targeter.nearbyCharacter.position + new float3(0, 0.1f, 0);
         float3 angle          = math.normalizesafe(targetPosition - positionValue);
         ////float3 upAngle = new float3(0, 1, 0);// math.cross(targetPosition, targetPosition);
         //aimer.targetRotation = Quaternion.Euler(angle);// quaternion.LookRotationSafe(angle, upAngle);
         aimer.targetRotation = quaternion.LookRotationSafe(angle, new float3(0, 1, 0));
         //aimer.targetRotation = quaternion.LookRotationSafe(angle, math.normalizesafe(math.cross(targetPosition, positionValue)));
         shooter.triggered = 1;
     }
     else
     {
         //turret.targetRotation = quaternion.EulerXYZ(new float3(90, 0, 0));
         shooter.triggered = 0;
     }
     rotation.Value        = QuaternionHelpers.slerpSafe(rotation.Value, aimer.targetRotation, deltaTime * aimer.turnSpeed);
     position.Value        = aimer.originalPosition + math.mul(aimer.targetRotation, new float3(0, 0, aimer.offsetZ / 4f));
     shooter.shootPosition = aimer.originalPosition + math.mul(aimer.targetRotation, new float3(0, 0, aimer.offsetZ + 0.2f));
     shooter.shootRotation = rotation.Value;
 }
Esempio n. 6
0
 public void Execute(ref AIState brain, ref Wander wander, ref BodyForce body, ref BodyTorque torque, ref BodyInnerForce innerBody, ref Rotation rotation)
 {
     if (brain.state == 1)
     {
         if (wander.thinking == 0)
         {
             body.velocity      = new float3(0, 0, innerBody.movementForce);
             wander.targetAngle = (new float3(0, wander.random.NextFloat(0, 360), 0));
             if (time - wander.lastWandered >= wander.wanderCooldown)
             {
                 wander.lastWandered = time;
                 if (wander.Value.waitCooldownMin != 0 && wander.Value.waitCooldownMax != 0)
                 {
                     wander.thinking     = 1;
                     wander.waitCooldown = wander.random.NextFloat(wander.Value.waitCooldownMin, wander.Value.waitCooldownMax);
                 }
             }
         }
         else
         {
             body.velocity = new float3();
             if (time - wander.lastWandered >= wander.waitCooldown)
             {
                 wander.lastWandered   = time;
                 wander.wanderCooldown = wander.random.NextFloat(wander.Value.wanderCooldownMin, wander.Value.wanderCooldownMax);
                 wander.thinking       = 0;
             }
         }
         quaternion newAngle = QuaternionHelpers.slerp(
             rotation.Value,
             quaternion.Euler(wander.targetAngle),
             deltaTime * innerBody.movementTorque);
         Quaternion newAngle2 = new Quaternion(newAngle.value.x, newAngle.value.y, newAngle.value.z, newAngle.value.w);
         rotation.Value = newAngle2;
     }
 }