Skip to content

Commit

Permalink
Merge pull request #314 from Amsterdam/release/2.8.1
Browse files Browse the repository at this point in the history
Release/2.8.1
  • Loading branch information
sambaas authored Sep 9, 2021
2 parents e2fe21e + e642241 commit 4b2fa83
Show file tree
Hide file tree
Showing 40 changed files with 94 additions and 84 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions 3DAmsterdam/Assets/Netherlands3D/Prefabs/UI/Compass.prefab

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 29 additions & 9 deletions 3DAmsterdam/Assets/Netherlands3D/Scripts/Cameras/GodViewCamera.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ public class GodViewCamera : MonoBehaviour, ICameraControls
[SerializeField]
private float spinSpeed = 0.5f;

[SerializeField]
private float firstPersonModifierSpinSpeed = 0.5f;

private const float minOrtographicZoom = 20f;
private float maxZoomOut = 2500f;
private float minUndergroundY = -30f;
Expand Down Expand Up @@ -68,7 +71,7 @@ public class GodViewCamera : MonoBehaviour, ICameraControls

private Vector3 zoomDirection;
private Vector3 rotatePoint;

private Vector3 localOffsetVector;
private Vector2 currentRotation;

public delegate void FocusPointChanged(Vector3 pointerPosition);
Expand Down Expand Up @@ -394,8 +397,8 @@ private void FirstPersonLook()
var mouseDelta = Mouse.current.delta.ReadValue();

//Convert mouse position into local rotations
currentRotation.x += mouseDelta.x * spinSpeed * ApplicationSettings.settings.rotateSensitivity;
currentRotation.y -= mouseDelta.y * spinSpeed * ApplicationSettings.settings.rotateSensitivity;
currentRotation.x -= mouseDelta.x * firstPersonModifierSpinSpeed * ApplicationSettings.settings.rotateSensitivity;
currentRotation.y += mouseDelta.y * firstPersonModifierSpinSpeed * ApplicationSettings.settings.rotateSensitivity;

//Adjust camera rotation
cameraComponent.transform.rotation = Quaternion.Euler(currentRotation.y, currentRotation.x, 0);
Expand Down Expand Up @@ -428,6 +431,9 @@ private void ZoomInDirection(float zoomAmount, Vector3 zoomDirectionPoint)
{
var cameraHeight = cameraComponent.transform.position.y; //The higher we are, the faster we zoom

//Inverse zoom multiplier when we are below the zoompoint
if (zoomDirectionPoint.y > cameraComponent.transform.position.y) zoomAmount *= -1;

if (cameraComponent.orthographic)
{
cameraComponent.orthographicSize = Mathf.Clamp(cameraComponent.orthographicSize - cameraComponent.orthographicSize * zoomAmount * zoomSpeed, minOrtographicZoom, maxZoomOut);
Expand Down Expand Up @@ -579,21 +585,35 @@ public bool UsesActionMap(InputActionMap actionMap)

public void ToggleOrtographic(bool ortographicOn)
{
cameraComponent.orthographic = ortographicOn;

if (ortographicOn)
{
//Set the orto size according to camera height, so our fov looks a bit like the perspective fov
var twoDimensionalUp = cameraComponent.transform.up;
twoDimensionalUp.y = 0;

var worldViewCenter = GetPointerPositionInWorld(new Vector3(Screen.width / 2, Screen.height / 2, 0));
cameraComponent.transform.localEulerAngles = new Vector3(0, cameraComponent.transform.localEulerAngles.y, cameraComponent.transform.localEulerAngles.z);
localOffsetVector = cameraComponent.transform.InverseTransformPoint(worldViewCenter);

//Shift camera to this point, but keep same height
cameraComponent.transform.position = new Vector3(worldViewCenter.x,cameraComponent.transform.position.y, worldViewCenter.z);
cameraComponent.transform.rotation = Quaternion.LookRotation(cameraComponent.transform.up, twoDimensionalUp);

//Set orto size based on camera height (to get a similar fov)
cameraComponent.orthographicSize = cameraComponent.transform.position.y;

//Slide forward based on camera angle, to get an expected centerpoint for our view
var forwardAmount = Vector3.Dot(cameraComponent.transform.up, Vector3.up);
cameraComponent.transform.Translate(cameraComponent.transform.up * forwardAmount * cameraComponent.transform.position.y);
print("Ortographic");
}
else{
var worldViewCenter = GetPointerPositionInWorld(new Vector3(Screen.width / 2, Screen.height / 2, 0));

cameraComponent.transform.position = worldViewCenter;
cameraComponent.transform.localEulerAngles = new Vector3(0, cameraComponent.transform.localEulerAngles.y, cameraComponent.transform.localEulerAngles.z);
cameraComponent.transform.Translate(-localOffsetVector, Space.Self);
cameraComponent.transform.LookAt(worldViewCenter);
print("Perspective");
}

cameraComponent.orthographic = ortographicOn;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,10 @@ public void Init(Material target, Color resetColor, LayerVisuals targetLayerVisu
}
//Set tooltip text. Users do not need to know if a material is an instance.
var materialName = targetMaterial.name.Replace(" (Instance)", "");
if (materialName.Contains("_")) materialName = materialName.Split('_')[0];

//Filter out our externail textures tag
if (materialName.Contains("[texture="))
materialName = materialName.Split('[')[0].Trim();

//GetComponent<TooltipTrigger>().TooltipText = materialName + EXPLANATION_TEXT;
materialTitle.text = materialName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,11 @@ namespace Netherlands3D.LayerSystem
public class FlipToCamera : MonoBehaviour
{
private float currentAngle;

public List<string> UniqueNamesList { get; internal set; }

void Start()
{
currentAngle = transform.transform.localRotation.eulerAngles.y;
if (currentAngle < 0)
{
currentAngle += 360;
}
}

private void OnDestroy()
Expand All @@ -50,24 +45,22 @@ void Update()
private void FlipTextByLookDirection()
{
float cameraAngle = CameraModeChanger.Instance.ActiveCamera.transform.rotation.eulerAngles.y;
bool flip = false;
float angleDelta;
angleDelta = Mathf.DeltaAngle(cameraAngle, currentAngle);

//Flip so the text is not upside down in the camera view
if (Mathf.Abs(angleDelta) > 90)
{
flip = true;
}

if (flip)
{
transform.Rotate(Vector3.forward, 180f, Space.Self);
currentAngle = transform.transform.localRotation.eulerAngles.y;
if (currentAngle < 0)
{
currentAngle += 360;
}
}

//Turn down if camera is below the text
this.transform.localEulerAngles = new Vector3(
(CameraModeChanger.Instance.ActiveCamera.transform.position.y < this.transform.position.y) ? -90 : 90,
this.transform.localEulerAngles.y,
this.transform.localEulerAngles.z
);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ private IEnumerator LoadTextures()
foreach (Material material in materialLibrary)
{
//If this material name contains an underscore, use the last part as a texture path
if (material.name.Contains("_"))
if (material.name.Contains("[texture="))
{
var materialTextureFileName = material.name.Split('_')[1];
var materialTextureFileName = material.name.Split('=')[1].Replace("]","");
if (loadedTextures.ContainsKey(materialTextureFileName))
{
material.SetTexture(materialBaseMap, loadedTextures[materialTextureFileName]);
Expand Down
Loading

0 comments on commit 4b2fa83

Please sign in to comment.