Skip to content

Commit

Permalink
Fix indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenvergenz committed Nov 9, 2017
1 parent 737135d commit e8e86ee
Show file tree
Hide file tree
Showing 12 changed files with 239 additions and 239 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,62 +6,62 @@

namespace GLTF.Schema
{
public class ExtTextureTransformExtension : Extension
{
/// <summary>
/// The offset of the UV coordinate origin as a percentage of the texture dimensions.
/// </summary>
public Vector2 Offset = new Vector2(0, 0);
public static readonly Vector2 OFFSET_DEFAULT = new Vector2(0, 0);
public class ExtTextureTransformExtension : Extension
{
/// <summary>
/// The offset of the UV coordinate origin as a percentage of the texture dimensions.
/// </summary>
public Vector2 Offset = new Vector2(0, 0);
public static readonly Vector2 OFFSET_DEFAULT = new Vector2(0, 0);

/// <summary>
/// The scale factor applied to the components of the UV coordinates.
/// </summary>
public Vector2 Scale = new Vector2(1, 1);
public static readonly Vector2 SCALE_DEFAULT = new Vector2(1, 1);
/// <summary>
/// The scale factor applied to the components of the UV coordinates.
/// </summary>
public Vector2 Scale = new Vector2(1, 1);
public static readonly Vector2 SCALE_DEFAULT = new Vector2(1, 1);

/// <summary>
/// Overrides the textureInfo texCoord value if this extension is supported.
/// </summary>
public int TexCoord = 0;
public static readonly int TEXCOORD_DEFAULT = 0;
/// <summary>
/// Overrides the textureInfo texCoord value if this extension is supported.
/// </summary>
public int TexCoord = 0;
public static readonly int TEXCOORD_DEFAULT = 0;

public ExtTextureTransformExtension(Vector2 offset, Vector2 scale, int texCoord)
{
Offset = offset;
Scale = scale;
TexCoord = texCoord;
}
public ExtTextureTransformExtension(Vector2 offset, Vector2 scale, int texCoord)
{
Offset = offset;
Scale = scale;
TexCoord = texCoord;
}

public JProperty Serialize()
{
JObject ext = new JObject();
public JProperty Serialize()
{
JObject ext = new JObject();

if (Offset != OFFSET_DEFAULT)
{
ext.Add(new JProperty(
ExtTextureTransformExtensionFactory.OFFSET,
new JArray(Offset.X, Offset.Y)
));
}
if (Scale != SCALE_DEFAULT)
{
ext.Add(new JProperty(
ExtTextureTransformExtensionFactory.SCALE,
new JArray(Scale.X, Scale.Y)
));
}
if (Offset != OFFSET_DEFAULT)
{
ext.Add(new JProperty(
ExtTextureTransformExtensionFactory.OFFSET,
new JArray(Offset.X, Offset.Y)
));
}
if (Scale != SCALE_DEFAULT)
{
ext.Add(new JProperty(
ExtTextureTransformExtensionFactory.SCALE,
new JArray(Scale.X, Scale.Y)
));
}

if (TexCoord != TEXCOORD_DEFAULT)
{
ext.Add(new JProperty(
ExtTextureTransformExtensionFactory.TEXCOORD,
TexCoord
));
}
if (TexCoord != TEXCOORD_DEFAULT)
{
ext.Add(new JProperty(
ExtTextureTransformExtensionFactory.TEXCOORD,
TexCoord
));
}

return new JProperty(ExtTextureTransformExtensionFactory.EXTENSION_NAME, ext);
}
}
return new JProperty(ExtTextureTransformExtensionFactory.EXTENSION_NAME, ext);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,37 +4,37 @@

namespace GLTF.Schema
{
public class ExtTextureTransformExtensionFactory : ExtensionFactory
{
public const string EXTENSION_NAME = "EXT_texture_transform";
public const string OFFSET = "offset";
public const string SCALE = "scale";
public const string TEXCOORD = "texCoord";
public class ExtTextureTransformExtensionFactory : ExtensionFactory
{
public const string EXTENSION_NAME = "EXT_texture_transform";
public const string OFFSET = "offset";
public const string SCALE = "scale";
public const string TEXCOORD = "texCoord";

public ExtTextureTransformExtensionFactory()
{
ExtensionName = EXTENSION_NAME;
}
public ExtTextureTransformExtensionFactory()
{
ExtensionName = EXTENSION_NAME;
}

public override Extension Deserialize(GLTFRoot root, JProperty extensionToken)
{
Vector2 offset = new Vector2(ExtTextureTransformExtension.OFFSET_DEFAULT);
Vector2 scale = new Vector2(ExtTextureTransformExtension.SCALE_DEFAULT);
int texCoord = ExtTextureTransformExtension.TEXCOORD_DEFAULT;
public override Extension Deserialize(GLTFRoot root, JProperty extensionToken)
{
Vector2 offset = new Vector2(ExtTextureTransformExtension.OFFSET_DEFAULT);
Vector2 scale = new Vector2(ExtTextureTransformExtension.SCALE_DEFAULT);
int texCoord = ExtTextureTransformExtension.TEXCOORD_DEFAULT;

if (extensionToken != null)
{
JToken offsetToken = extensionToken.Value[OFFSET];
offset = offsetToken != null ? offsetToken.DeserializeAsVector2() : offset;
if (extensionToken != null)
{
JToken offsetToken = extensionToken.Value[OFFSET];
offset = offsetToken != null ? offsetToken.DeserializeAsVector2() : offset;

JToken scaleToken = extensionToken.Value[SCALE];
scale = scaleToken != null ? scaleToken.DeserializeAsVector2() : scale;
JToken scaleToken = extensionToken.Value[SCALE];
scale = scaleToken != null ? scaleToken.DeserializeAsVector2() : scale;

JToken texCoordToken = extensionToken.Value[TEXCOORD];
texCoord = texCoordToken != null ? texCoordToken.DeserializeAsInt() : texCoord;
}
return new ExtTextureTransformExtension(offset, scale, texCoord);
}
}
JToken texCoordToken = extensionToken.Value[TEXCOORD];
texCoord = texCoordToken != null ? texCoordToken.DeserializeAsInt() : texCoord;
}
return new ExtTextureTransformExtension(offset, scale, texCoord);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -221,33 +221,33 @@ public static Vector3 ReadAsVector3(this JsonReader reader)
return vector;
}

public static Vector2 DeserializeAsVector2(this JToken token)
{
Vector2 vector = new Vector2();

if (token != null)
{
JArray vectorArray = token as JArray;
if (vectorArray == null)
{
throw new Exception("JToken used for Vector2 deserialization was not a JArray. It was a " + token.Type.ToString());
}
if (vectorArray.Count != 2)
{
throw new Exception("JArray used for Vector2 deserialization did not have 2 entries for XY. It had " + vectorArray.Count);
}

vector = new Vector2
{
X = (float)vectorArray[0].DeserializeAsDouble(),
Y = (float)vectorArray[1].DeserializeAsDouble()
};
}

return vector;
}

public static Vector3 DeserializeAsVector3(this JToken token)
public static Vector2 DeserializeAsVector2(this JToken token)
{
Vector2 vector = new Vector2();

if (token != null)
{
JArray vectorArray = token as JArray;
if (vectorArray == null)
{
throw new Exception("JToken used for Vector2 deserialization was not a JArray. It was a " + token.Type.ToString());
}
if (vectorArray.Count != 2)
{
throw new Exception("JArray used for Vector2 deserialization did not have 2 entries for XY. It had " + vectorArray.Count);
}

vector = new Vector2
{
X = (float)vectorArray[0].DeserializeAsDouble(),
Y = (float)vectorArray[1].DeserializeAsDouble()
};
}

return vector;
}

public static Vector3 DeserializeAsVector3(this JToken token)
{
Vector3 vector = new Vector3();

Expand Down
14 changes: 7 additions & 7 deletions GLTFSerialization/GLTFSerialization/Math/Color.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ public Color(float r, float g, float b, float a)
A = a;
}

public Color(Color other)
{
R = other.R;
G = other.G;
B = other.B;
A = other.A;
}
public Color(Color other)
{
R = other.R;
G = other.G;
B = other.B;
A = other.A;
}

public static bool operator ==(Color left, Color right)
{
Expand Down
8 changes: 4 additions & 4 deletions GLTFSerialization/GLTFSerialization/Math/Matrix4x4.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ public Matrix4x4(float m11, float m21, float m31, float m41, float m12, float m2
M44 = m44;
}

public Matrix4x4(Matrix4x4 other)
{
Array.Copy(other.mat, 0, mat, 0, 16);
}
public Matrix4x4(Matrix4x4 other)
{
Array.Copy(other.mat, 0, mat, 0, 16);
}

public override bool Equals(object obj)
{
Expand Down
14 changes: 7 additions & 7 deletions GLTFSerialization/GLTFSerialization/Math/Quaternion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ public Quaternion(float x, float y, float z, float w)
W = w;
}

public Quaternion(Quaternion other)
{
X = other.X;
Y = other.Y;
Z = other.Z;
W = other.W;
}
public Quaternion(Quaternion other)
{
X = other.X;
Y = other.Y;
Z = other.Z;
W = other.W;
}

public override bool Equals(object obj)
{
Expand Down
10 changes: 5 additions & 5 deletions GLTFSerialization/GLTFSerialization/Math/Vector2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ public Vector2(float x, float y)
Y = y;
}

public Vector2(Vector2 other)
{
X = other.X;
Y = other.Y;
}
public Vector2(Vector2 other)
{
X = other.X;
Y = other.Y;
}

public override bool Equals(object obj)
{
Expand Down
12 changes: 6 additions & 6 deletions GLTFSerialization/GLTFSerialization/Math/Vector3.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ public Vector3(float x, float y, float z)
Z = z;
}

public Vector3(Vector3 other)
{
X = other.X;
Y = other.Y;
Z = other.Z;
}
public Vector3(Vector3 other)
{
X = other.X;
Y = other.Y;
Z = other.Z;
}

public override bool Equals(object obj)
{
Expand Down
14 changes: 7 additions & 7 deletions GLTFSerialization/GLTFSerialization/Math/Vector4.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ public Vector4(float x, float y, float z, float w)
W = w;
}

public Vector4(Vector4 other)
{
X = other.X;
Y = other.Y;
Z = other.Z;
W = other.W;
}
public Vector4(Vector4 other)
{
X = other.X;
Y = other.Y;
Z = other.Z;
W = other.W;
}

public override bool Equals(object obj)
{
Expand Down
12 changes: 6 additions & 6 deletions GLTFSerialization/GLTFSerialization/Schema/GLTFProperty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class GLTFProperty
private static Dictionary<string, ExtensionFactory> _extensionRegistry = new Dictionary<string, ExtensionFactory>();
private static DefaultExtensionFactory _defaultExtensionFactory = new DefaultExtensionFactory();
private static KHR_materials_pbrSpecularGlossinessExtensionFactory _KHRExtensionFactory = new KHR_materials_pbrSpecularGlossinessExtensionFactory();
private static ExtTextureTransformExtensionFactory _TexTransformFactory = new ExtTextureTransformExtensionFactory();
private static ExtTextureTransformExtensionFactory _TexTransformFactory = new ExtTextureTransformExtensionFactory();

public static void RegisterExtension(ExtensionFactory extensionFactory)
{
Expand Down Expand Up @@ -111,11 +111,11 @@ private Dictionary<string, Extension> DeserializeExtensions(GLTFRoot root, JsonR
{
extensions.Add(extensionName, _KHRExtensionFactory.Deserialize(root, (JProperty)extensionToken));
}
else if (extensionName.Equals(ExtTextureTransformExtensionFactory.EXTENSION_NAME))
{
extensions.Add(extensionName, _TexTransformFactory.Deserialize(root, (JProperty)extensionToken));
}
else
else if (extensionName.Equals(ExtTextureTransformExtensionFactory.EXTENSION_NAME))
{
extensions.Add(extensionName, _TexTransformFactory.Deserialize(root, (JProperty)extensionToken));
}
else
{
extensions.Add(extensionName, _defaultExtensionFactory.Deserialize(root, (JProperty)extensionToken));
}
Expand Down
Loading

0 comments on commit e8e86ee

Please sign in to comment.