예제 #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));
            }
예제 #2
0
파일: OrbitCamera.cs 프로젝트: Deus0/zoxel
        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);
        }
예제 #3
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);
            }
예제 #4
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;
 }