Skip to content

Commit

Permalink
Merge branch 'develop' into feature-crea
Browse files Browse the repository at this point in the history
  • Loading branch information
Yannick committed Oct 17, 2016
2 parents acaaa8b + 1f85ba1 commit 98b7cdf
Show file tree
Hide file tree
Showing 8 changed files with 243 additions and 93 deletions.
22 changes: 11 additions & 11 deletions Assets/Resources/UI/Scroll.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
m_IsActive: 0
--- !u!1 &1000012999628682
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -437,10 +437,10 @@ RectTransform:
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1000012419793782}
m_LocalRotation: {x: 0, y: 0, z: 1, w: 0}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 180}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_Children: []
m_Father: {fileID: 224000011745562128}
m_RootOrder: 0
Expand All @@ -462,10 +462,10 @@ RectTransform:
m_Children: []
m_Father: {fileID: 224000013729713610}
m_RootOrder: 1
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 586, y: -22.3}
m_SizeDelta: {x: 378, y: 44.6}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!224 &224000011605903510
RectTransform:
Expand Down Expand Up @@ -519,10 +519,10 @@ RectTransform:
m_Children: []
m_Father: {fileID: 224000013729713610}
m_RootOrder: 0
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 211, y: -22.3}
m_SizeDelta: {x: 372, y: 44.6}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!224 &224000013729713610
RectTransform:
Expand Down
64 changes: 0 additions & 64 deletions Assets/Scenes/Scene.unity
Original file line number Diff line number Diff line change
Expand Up @@ -187,70 +187,6 @@ Prefab:
propertyPath: m_Pivot.y
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 224000013427748204, guid: 0beda27bcd6e09c4cb8135ce4f3028b6,
type: 2}
propertyPath: m_AnchorMin.y
value: 1
objectReference: {fileID: 0}
- target: {fileID: 224000013427748204, guid: 0beda27bcd6e09c4cb8135ce4f3028b6,
type: 2}
propertyPath: m_AnchorMax.y
value: 1
objectReference: {fileID: 0}
- target: {fileID: 224000013427748204, guid: 0beda27bcd6e09c4cb8135ce4f3028b6,
type: 2}
propertyPath: m_AnchoredPosition.x
value: 211
objectReference: {fileID: 0}
- target: {fileID: 224000013427748204, guid: 0beda27bcd6e09c4cb8135ce4f3028b6,
type: 2}
propertyPath: m_AnchoredPosition.y
value: -22.3
objectReference: {fileID: 0}
- target: {fileID: 224000013427748204, guid: 0beda27bcd6e09c4cb8135ce4f3028b6,
type: 2}
propertyPath: m_SizeDelta.x
value: 372
objectReference: {fileID: 0}
- target: {fileID: 224000013427748204, guid: 0beda27bcd6e09c4cb8135ce4f3028b6,
type: 2}
propertyPath: m_SizeDelta.y
value: 44.6
objectReference: {fileID: 0}
- target: {fileID: 224000011592282706, guid: 0beda27bcd6e09c4cb8135ce4f3028b6,
type: 2}
propertyPath: m_AnchorMin.y
value: 1
objectReference: {fileID: 0}
- target: {fileID: 224000011592282706, guid: 0beda27bcd6e09c4cb8135ce4f3028b6,
type: 2}
propertyPath: m_AnchorMax.y
value: 1
objectReference: {fileID: 0}
- target: {fileID: 224000011592282706, guid: 0beda27bcd6e09c4cb8135ce4f3028b6,
type: 2}
propertyPath: m_AnchoredPosition.x
value: 586
objectReference: {fileID: 0}
- target: {fileID: 224000011592282706, guid: 0beda27bcd6e09c4cb8135ce4f3028b6,
type: 2}
propertyPath: m_AnchoredPosition.y
value: -22.3
objectReference: {fileID: 0}
- target: {fileID: 224000011592282706, guid: 0beda27bcd6e09c4cb8135ce4f3028b6,
type: 2}
propertyPath: m_SizeDelta.x
value: 378
objectReference: {fileID: 0}
- target: {fileID: 224000011592282706, guid: 0beda27bcd6e09c4cb8135ce4f3028b6,
type: 2}
propertyPath: m_SizeDelta.y
value: 44.6
objectReference: {fileID: 0}
- target: {fileID: 1000012704847176, guid: 0beda27bcd6e09c4cb8135ce4f3028b6, type: 2}
propertyPath: m_IsActive
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: 0beda27bcd6e09c4cb8135ce4f3028b6, type: 2}
m_IsPrefabParent: 0
Expand Down
212 changes: 210 additions & 2 deletions Assets/Scripts/Core/UnityBinaryReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ public Matrix4x4 ReadLEColumnMajorMatrix3x3()
for(int rowIndex = 0; rowIndex < 4; rowIndex++)
{
// If we're in the 3x3 part of the matrix, read values. Otherwise, use the identity matrix.
if(rowIndex <= 2 && columnIndex <= 2)
if((rowIndex <= 2) && (columnIndex <= 2))
{
matrix[rowIndex, columnIndex] = ReadLESingle();
}
Expand All @@ -233,7 +233,7 @@ public Matrix4x4 ReadLERowMajorMatrix3x3()
for(int columnIndex = 0; columnIndex < 4; columnIndex++)
{
// If we're in the 3x3 part of the matrix, read values. Otherwise, use the identity matrix.
if(rowIndex <= 2 && columnIndex <= 2)
if((rowIndex <= 2) && (columnIndex <= 2))
{
matrix[rowIndex, columnIndex] = ReadLESingle();
}
Expand Down Expand Up @@ -296,6 +296,214 @@ public Quaternion ReadLEQuaternionWLast()
}
#endregion

#region Big Endian
public bool ReadBEBool32()
{
return ReadBEUInt32() != 0;
}

public ushort ReadBEUInt16()
{
reader.Read(readBuffer, 0, 2);

return (ushort)((readBuffer[0] << 8) | readBuffer[1]);
}
public uint ReadBEUInt32()
{
reader.Read(readBuffer, 0, 4);

return ((uint)readBuffer[0] << 24) | ((uint)readBuffer[1] << 16) | ((uint)readBuffer[2] << 8) | readBuffer[3];
}
public ulong ReadBEUInt64()
{
reader.Read(readBuffer, 0, 8);

return ((ulong)readBuffer[0] << 56) | ((ulong)readBuffer[1] << 48) | ((ulong)readBuffer[2] << 40) | ((ulong)readBuffer[3] << 32) | ((ulong)readBuffer[4] << 24) | ((ulong)readBuffer[5] << 16) | ((ulong)readBuffer[6] << 8) | readBuffer[7];
}

public short ReadBEInt16()
{
var shortAsUShort = ReadBEUInt16();

unsafe
{
return *((short*)(&shortAsUShort));
}
}
public int ReadBEInt32()
{
var intAsUInt = ReadBEUInt32();

unsafe
{
return *((int*)(&intAsUInt));
}
}
public long ReadBEInt64()
{
var longAsULong = ReadBEUInt64();

unsafe
{
return *((long*)(&longAsULong));
}
}

public float ReadBESingle()
{
var singleAsUInt = ReadBEUInt32();

unsafe
{
return *((float*)(&singleAsUInt));
}
}
public double ReadBEDouble()
{
var doubleAsUInt = ReadBEUInt64();

unsafe
{
return *((double*)(&doubleAsUInt));
}
}

public byte[] ReadBELength32PrefixedBytes()
{
var length = ReadBEUInt32();
return reader.ReadBytes((int)length);
}
public string ReadBELength32PrefixedASCIIString()
{
return System.Text.Encoding.ASCII.GetString(ReadBELength32PrefixedBytes());
}

public Vector2 ReadBEVector2()
{
var x = ReadBESingle();
var y = ReadBESingle();

return new Vector2(x, y);
}
public Vector3 ReadBEVector3()
{
var x = ReadBESingle();
var y = ReadBESingle();
var z = ReadBESingle();

return new Vector3(x, y, z);
}
public Vector4 ReadBEVector4()
{
var x = ReadBESingle();
var y = ReadBESingle();
var z = ReadBESingle();
var w = ReadBESingle();

return new Vector4(x, y, z, w);
}

/// <summary>
/// Reads a column-major 3x3 matrix but returns a functionally equivalent 4x4 matrix.
/// </summary>
public Matrix4x4 ReadBEColumnMajorMatrix3x3()
{
var matrix = new Matrix4x4();

for(int columnIndex = 0; columnIndex < 4; columnIndex++)
{
for(int rowIndex = 0; rowIndex < 4; rowIndex++)
{
// If we're in the 3x3 part of the matrix, read values. Otherwise, use the identity matrix.
if((rowIndex <= 2) && (columnIndex <= 2))
{
matrix[rowIndex, columnIndex] = ReadBESingle();
}
else
{
matrix[rowIndex, columnIndex] = (rowIndex == columnIndex) ? 1 : 0;
}
}
}

return matrix;
}

/// <summary>
/// Reads a row-major 3x3 matrix but returns a functionally equivalent 4x4 matrix.
/// </summary>
public Matrix4x4 ReadBERowMajorMatrix3x3()
{
var matrix = new Matrix4x4();

for(int rowIndex = 0; rowIndex < 4; rowIndex++)
{
for(int columnIndex = 0; columnIndex < 4; columnIndex++)
{
// If we're in the 3x3 part of the matrix, read values. Otherwise, use the identity matrix.
if((rowIndex <= 2) && (columnIndex <= 2))
{
matrix[rowIndex, columnIndex] = ReadBESingle();
}
else
{
matrix[rowIndex, columnIndex] = (rowIndex == columnIndex) ? 1 : 0;
}
}
}

return matrix;
}

public Matrix4x4 ReadBEColumnMajorMatrix4x4()
{
var matrix = new Matrix4x4();

for(int columnIndex = 0; columnIndex < 4; columnIndex++)
{
for(int rowIndex = 0; rowIndex < 4; rowIndex++)
{
matrix[rowIndex, columnIndex] = ReadBESingle();
}
}

return matrix;
}
public Matrix4x4 ReadBERowMajorMatrix4x4()
{
var matrix = new Matrix4x4();

for(int rowIndex = 0; rowIndex < 4; rowIndex++)
{
for(int columnIndex = 0; columnIndex < 4; columnIndex++)
{
matrix[rowIndex, columnIndex] = ReadBESingle();
}
}

return matrix;
}

public Quaternion ReadBEQuaternionWFirst()
{
float w = ReadBESingle();
float x = ReadBESingle();
float y = ReadBESingle();
float z = ReadBESingle();

return new Quaternion(x, y, z, w);
}
public Quaternion ReadBEQuaternionWLast()
{
float x = ReadBESingle();
float y = ReadBESingle();
float z = ReadBESingle();
float w = ReadBESingle();

return new Quaternion(x, y, z, w);
}
#endregion

private BinaryReader reader;

// A buffer for read bytes the size of a decimal variable. Created to minimize allocations.
Expand Down
8 changes: 4 additions & 4 deletions Assets/Scripts/TES/Components/PlayerComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ private void Start()
rigidbody = GetComponent<Rigidbody>();

// Add the crosshair
var textureManager = TESUnity.instance.Engine.textureManager;
var crosshairTexture = textureManager.LoadTexture("target");
var textureManager = TESUnity.instance.TextureManager;
var crosshairTexture = textureManager.LoadTexture("target", true);
_crosshair = GUIUtils.CreateImage(GUIUtils.CreateSprite(crosshairTexture), GUIUtils.MainCanvas, 35, 35);

// The crosshair needs an X and Y flip
//var cursor = textureManager.LoadTexture("tx_cursor");
//Cursor.SetCursor(cursor, Vector2.zero, CursorMode.Auto);
var cursor = textureManager.LoadTexture("tx_cursor", true);
Cursor.SetCursor(cursor, Vector2.zero, CursorMode.Auto);

leftHand = CreateHand(true);
rightHand = CreateHand(false);
Expand Down
8 changes: 3 additions & 5 deletions Assets/Scripts/TES/TESUnity.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using System;
using System.IO;
using System.IO;
using UnityEngine;
using UnityEngine.UI;

namespace TESUnity
{
Expand Down Expand Up @@ -63,9 +61,9 @@ public MorrowindEngine Engine
get { return MWEngine; }
}

public MorrowindDataReader DataReader
public TextureManager TextureManager
{
get { return MWDataReader; }
get { return MWEngine.textureManager; }
}

private void Awake()
Expand Down
Loading

0 comments on commit 98b7cdf

Please sign in to comment.