Commit daa136ca authored by Michael Schuh's avatar Michael Schuh
Browse files

Merge branch 'ImageTracking-with-pokercards' into 'master'

Image tracking with pokercards

See merge request !1
parents 40a45f83 c92ed067
No preview for this file type
......@@ -56,7 +56,6 @@ ExportedObj/
sysinfo.txt
# Builds
*.apk
*.aab
*.unitypackage
......
{
"files.exclude":
{
"**/.DS_Store":true,
"**/.git":true,
"**/.gitignore":true,
"**/.gitmodules":true,
"**/*.booproj":true,
"**/*.pidb":true,
"**/*.suo":true,
"**/*.user":true,
"**/*.userprefs":true,
"**/*.unityproj":true,
"**/*.dll":true,
"**/*.exe":true,
"**/*.pdf":true,
"**/*.mid":true,
"**/*.midi":true,
"**/*.wav":true,
"**/*.gif":true,
"**/*.ico":true,
"**/*.jpg":true,
"**/*.jpeg":true,
"**/*.png":true,
"**/*.psd":true,
"**/*.tga":true,
"**/*.tif":true,
"**/*.tiff":true,
"**/*.3ds":true,
"**/*.3DS":true,
"**/*.fbx":true,
"**/*.FBX":true,
"**/*.lxo":true,
"**/*.LXO":true,
"**/*.ma":true,
"**/*.MA":true,
"**/*.obj":true,
"**/*.OBJ":true,
"**/*.asset":true,
"**/*.cubemap":true,
"**/*.flare":true,
"**/*.mat":true,
"**/*.meta":true,
"**/*.prefab":true,
"**/*.unity":true,
"build/":true,
"Build/":true,
"Library/":true,
"library/":true,
"obj/":true,
"Obj/":true,
"ProjectSettings/":true,
"temp/":true,
"Temp/":true
}
}
\ No newline at end of file
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &7304075375816190111
--- !u!1 &5982633111859369057
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
......@@ -8,10 +8,10 @@ GameObject:
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 5253397335612988648}
- component: {fileID: 769726326801737886}
- component: {fileID: 7877162392316135787}
- component: {fileID: 482226916462650051}
- component: {fileID: 5982633111859369062}
- component: {fileID: 5982633111859369061}
- component: {fileID: 5982633111859369060}
- component: {fileID: 5982633111859369063}
m_Layer: 0
m_Name: Cube
m_TagString: Untagged
......@@ -19,35 +19,35 @@ GameObject:
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &5253397335612988648
--- !u!4 &5982633111859369062
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7304075375816190111}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0.35000047, y: -0.7261724, z: 0.00000047683716}
m_LocalScale: {x: 0.5, y: 0.5, z: 0.5}
m_GameObject: {fileID: 5982633111859369057}
m_LocalRotation: {x: 0.46193978, y: 0.19134173, z: 0.19134173, w: 0.84462327}
m_LocalPosition: {x: -0.0002, y: 0.0203, z: 0.0007}
m_LocalScale: {x: 0.02, y: 0.02, z: 0.02}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!33 &769726326801737886
m_LocalEulerAnglesHint: {x: 45, y: 45, z: 45}
--- !u!33 &5982633111859369061
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7304075375816190111}
m_GameObject: {fileID: 5982633111859369057}
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
--- !u!23 &7877162392316135787
--- !u!23 &5982633111859369060
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7304075375816190111}
m_GameObject: {fileID: 5982633111859369057}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
......@@ -82,13 +82,13 @@ MeshRenderer:
m_SortingLayer: 0
m_SortingOrder: 0
m_AdditionalVertexStreams: {fileID: 0}
--- !u!65 &482226916462650051
--- !u!65 &5982633111859369063
BoxCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7304075375816190111}
m_GameObject: {fileID: 5982633111859369057}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
......
fileFormatVersion: 2
guid: 558186eaa4c4a4280a9606bbfb1152e6
guid: 0675055ff7ac742f3a35fe36667670a4
PrefabImporter:
externalObjects: {}
userData:
......
fileFormatVersion: 2
guid: 833e12f1d550f2c4b96eb6fa3a5ea199
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 784c1ed2aa16453488a41efb0eeae8ce
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
using System;
using System.IO;
using System.Linq;
using System.Text;
using UnityEditor;
using UnityEngine;
[InitializeOnLoad]
public class AddVuforiaEnginePackage
{
static readonly string sPackagesPath = Path.Combine(Application.dataPath, "..", "Packages");
static readonly string sManifestJsonPath = Path.Combine(sPackagesPath, "manifest.json");
const string VUFORIA_VERSION = "9.8.8";
const string PACKAGE_KEY = "com.ptc.vuforia.engine";
const string GIT_URL = "git+https://git-packages.developer.vuforia.com";
static readonly ScopedRegistry sVuforiaRegistry = new ScopedRegistry()
{
name = "Vuforia",
url = "https://registry.packages.developer.vuforia.com/",
scopes = new[] {"com.ptc.vuforia"}
};
static AddVuforiaEnginePackage()
{
if (Application.isBatchMode)
return;
var manifest = Manifest.JsonDeserialize(sManifestJsonPath);
if (!IsUsingRightGitUrl(manifest))
DisplayAddPackageDialogue(manifest);
}
static bool IsUsingRightGitUrl(Manifest manifest)
{
var dependencies = manifest.Dependencies.Split(',').ToList();
return dependencies.Any(d => d.Contains(PACKAGE_KEY) && d.Contains(GIT_URL) && VersionNumberIsTheLatest(d));
}
static bool VersionNumberIsTheLatest(string package)
{
var version = package.Split('#');
if (version.Length >= 2)
{
version[1] = version[1].TrimEnd(new []{ '"' });
return IsCurrentVersionHigher(version[1]);
}
return false;
}
static bool IsCurrentVersionHigher(string currentVersionString)
{
if (string.IsNullOrEmpty(currentVersionString) || string.IsNullOrEmpty(VUFORIA_VERSION))
return false;
var currentVersion = TryConvertStringToVersion(currentVersionString);
var updatingVersion = TryConvertStringToVersion(VUFORIA_VERSION);
if (currentVersion >= updatingVersion)
return true;
return false;
}
static Version TryConvertStringToVersion(string versionString)
{
Version res;
try
{
res = new Version(versionString);
}
catch (Exception e)
{
return new Version();
}
return new Version(res.Major, res.Minor, res.Build);
}
static void DisplayAddPackageDialogue(Manifest manifest)
{
if (EditorUtility.DisplayDialog("Add Vuforia Engine Package",
$"Would you like to update your project to include the Vuforia Engine {VUFORIA_VERSION} package from Git?\n" +
$"If an older Vuforia Engine package is already present in your project it will be upgraded to version {VUFORIA_VERSION}\n\n" +
$"Please make sure that Git is installed and on your PATH environment variable.", "Update", "Cancel"))
{
UpdateManifest(manifest);
}
}
static void UpdateManifest(Manifest manifest)
{
//remove existing, outdated NPM scoped registry if present
var registries = manifest.ScopedRegistries.ToList();
if (registries.Contains(sVuforiaRegistry))
{
registries.Remove(sVuforiaRegistry);
manifest.ScopedRegistries = registries.ToArray();
}
//add specified vuforia version via Git URL
SetVuforiaVersion(manifest);
manifest.JsonSerialize(sManifestJsonPath);
AssetDatabase.Refresh();
}
static void SetVuforiaVersion(Manifest manifest)
{
var dependencies = manifest.Dependencies.Split(',').ToList();
var versionEntry = $"\"{GIT_URL}#{VUFORIA_VERSION}\"";
var versionSet = false;
for (var i = 0; i < dependencies.Count; i++)
{
if (!dependencies[i].Contains(PACKAGE_KEY))
continue;
var kvp = dependencies[i].Split(':');
dependencies[i] = kvp[0] + ": " + versionEntry;
versionSet = true;
}
if (!versionSet)
dependencies.Insert(0, $"\n \"{PACKAGE_KEY}\": {versionEntry}");
manifest.Dependencies = string.Join(",", dependencies);
}
class Manifest
{
const int INDEX_NOT_FOUND = -1;
const string DEPENDENCIES_KEY = "\"dependencies\"";
public ScopedRegistry[] ScopedRegistries;
public string Dependencies;
public void JsonSerialize(string path)
{
var jsonString = GetJsonString();
var startIndex = GetDependenciesStart(jsonString);
var endIndex = GetDependenciesEnd(jsonString, startIndex);
var stringBuilder = new StringBuilder();
stringBuilder.Append(jsonString.Substring(0, startIndex));
stringBuilder.Append(Dependencies);
stringBuilder.Append(jsonString.Substring(endIndex, jsonString.Length - endIndex));
File.WriteAllText(path, stringBuilder.ToString());
}
string GetJsonString()
{
if (ScopedRegistries.Length > 0)
return JsonUtility.ToJson(
new UnitySerializableManifest {scopedRegistries = ScopedRegistries, dependencies = new DependencyPlaceholder()},
true);
return JsonUtility.ToJson(
new UnitySerializableManifestDependenciesOnly() {dependencies = new DependencyPlaceholder()},
true);
}
public static Manifest JsonDeserialize(string path)
{
var jsonString = File.ReadAllText(path);
var registries = JsonUtility.FromJson<UnitySerializableManifest>(jsonString).scopedRegistries ?? new ScopedRegistry[0];
var dependencies = DeserializeDependencies(jsonString);
return new Manifest {ScopedRegistries = registries, Dependencies = dependencies};
}
static string DeserializeDependencies(string json)
{
var startIndex = GetDependenciesStart(json);
var endIndex = GetDependenciesEnd(json, startIndex);
if (startIndex == INDEX_NOT_FOUND || endIndex == INDEX_NOT_FOUND)
return null;
var dependencies = json.Substring(startIndex, endIndex - startIndex);
return dependencies;
}
static int GetDependenciesStart(string json)
{
var dependenciesIndex = json.IndexOf(DEPENDENCIES_KEY, StringComparison.InvariantCulture);
if (dependenciesIndex == INDEX_NOT_FOUND)
return INDEX_NOT_FOUND;
var dependenciesStartIndex = json.IndexOf('{', dependenciesIndex + DEPENDENCIES_KEY.Length);
if (dependenciesStartIndex == INDEX_NOT_FOUND)
return INDEX_NOT_FOUND;
dependenciesStartIndex++; //add length of '{' to starting point
return dependenciesStartIndex;
}
static int GetDependenciesEnd(string jsonString, int dependenciesStartIndex)
{
return jsonString.IndexOf('}', dependenciesStartIndex);
}
}
class UnitySerializableManifestDependenciesOnly
{
public DependencyPlaceholder dependencies;
}
class UnitySerializableManifest
{
public ScopedRegistry[] scopedRegistries;
public DependencyPlaceholder dependencies;
}
[Serializable]
struct ScopedRegistry
{
public string name;
public string url;
public string[] scopes;
public override bool Equals(object obj)
{
if (!(obj is ScopedRegistry))
return false;
var other = (ScopedRegistry) obj;
return name == other.name &&
url == other.url &&
scopes.SequenceEqual(other.scopes);
}
public static bool operator ==(ScopedRegistry a, ScopedRegistry b)
{
return a.Equals(b);
}
public static bool operator !=(ScopedRegistry a, ScopedRegistry b)
{
return !a.Equals(b);
}
public override int GetHashCode()
{
var hash = 17;
foreach (var scope in scopes)
hash = hash * 23 + (scope == null ? 0 : scope.GetHashCode());
hash = hash * 23 + (name == null ? 0 : name.GetHashCode());
hash = hash * 23 + (url == null ? 0 : url.GetHashCode());
return hash;
}
}
[Serializable]
struct DependencyPlaceholder { }
}
\ No newline at end of file
fileFormatVersion: 2
guid: 3bbef22eb814a9647b6c1f03e99d95da
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
{
"name": "EditorMigrationScripts",
"references": [],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": []
}
\ No newline at end of file
fileFormatVersion: 2
guid: f3a385ed4c943d742a2e7a85a3d4386d
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: e2ebd3229695f904ca6aec0bf9136be5
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 9a835b197ef6b5b26a1536eecbfb6b10
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 35fbef93cdbca29ceb9543d3bfa4bc98
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: bb9659d308a44c748c4186ea549f0e5e
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 11
mipmaps:
mipMapMode: 0
enableMipMap: 1
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 1
aniso: 1
mipBias: 0
wrapU: 0
wrapV: 0
wrapW: 0
nPOTScale: 1
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 0
spriteTessellationDetail: -1
textureType: 0
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 1
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Android
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0