init
This commit is contained in:
5
Assets/ArabicSupport.meta
Normal file
5
Assets/ArabicSupport.meta
Normal file
@@ -0,0 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c3502cad44c429a4dab63b2e5b90ce7b
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
userData:
|
||||
5
Assets/ArabicSupport/Scripts.meta
Normal file
5
Assets/ArabicSupport/Scripts.meta
Normal file
@@ -0,0 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f8af0aaae6053264b91bfc1fb5efe624
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
userData:
|
||||
972
Assets/ArabicSupport/Scripts/ArabicSupport.cs
Normal file
972
Assets/ArabicSupport/Scripts/ArabicSupport.cs
Normal file
@@ -0,0 +1,972 @@
|
||||
#region File Description
|
||||
//-----------------------------------------------------------------------------
|
||||
/// <summary>
|
||||
/// This is an Open Source File Created by: Abdullah Konash (http://abdullahkonash.com/) Twitter: @konash
|
||||
/// This File allow the users to use arabic text in XNA and Unity platform.
|
||||
/// It flips the characters and replace them with the appropriate ones to connect the letters in the correct way.
|
||||
/// </summary>
|
||||
//-----------------------------------------------------------------------------
|
||||
#endregion
|
||||
|
||||
|
||||
#region Using Statements
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
#endregion
|
||||
|
||||
namespace ArabicSupport
|
||||
{
|
||||
|
||||
public class ArabicFixer
|
||||
{
|
||||
/// <summary>
|
||||
/// Fix the specified string.
|
||||
/// </summary>
|
||||
/// <param name='str'>
|
||||
/// String to be fixed.
|
||||
/// </param>
|
||||
public static string Fix(string str)
|
||||
{
|
||||
return Fix(str, false, true);
|
||||
}
|
||||
|
||||
public static string Fix(string str, bool rtl)
|
||||
{
|
||||
if(rtl)
|
||||
|
||||
{
|
||||
return Fix(str);
|
||||
}
|
||||
else
|
||||
{
|
||||
string[] words = str.Split(' ');
|
||||
string result = "";
|
||||
string arabicToIgnore = "";
|
||||
foreach(string word in words)
|
||||
{
|
||||
if(char.IsLower(word.ToLower()[word.Length/2]))
|
||||
{
|
||||
result += Fix(arabicToIgnore) + word + " ";
|
||||
arabicToIgnore = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
arabicToIgnore += word + " ";
|
||||
|
||||
}
|
||||
}
|
||||
if(arabicToIgnore != "")
|
||||
result += Fix(arabicToIgnore);
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fix the specified string with customization options.
|
||||
/// </summary>
|
||||
/// <param name='str'>
|
||||
/// String to be fixed.
|
||||
/// </param>
|
||||
/// <param name='showTashkeel'>
|
||||
/// Show tashkeel.
|
||||
/// </param>
|
||||
/// <param name='useHinduNumbers'>
|
||||
/// Use hindu numbers.
|
||||
/// </param>
|
||||
public static string Fix(string str, bool showTashkeel, bool useHinduNumbers)
|
||||
{
|
||||
ArabicFixerTool.showTashkeel = showTashkeel;
|
||||
ArabicFixerTool.useHinduNumbers =useHinduNumbers;
|
||||
|
||||
if(str.Contains("\n"))
|
||||
str = str.Replace("\n", Environment.NewLine);
|
||||
|
||||
if(str.Contains(Environment.NewLine))
|
||||
{
|
||||
string[] stringSeparators = new string[] {Environment.NewLine};
|
||||
string[] strSplit = str.Split(stringSeparators, StringSplitOptions.None);
|
||||
|
||||
if(strSplit.Length == 0)
|
||||
return ArabicFixerTool.FixLine(str);
|
||||
else if(strSplit.Length == 1)
|
||||
return ArabicFixerTool.FixLine(str);
|
||||
else
|
||||
{
|
||||
string outputString = ArabicFixerTool.FixLine(strSplit[0]);
|
||||
int iteration = 1;
|
||||
if(strSplit.Length > 1)
|
||||
{
|
||||
while(iteration < strSplit.Length)
|
||||
{
|
||||
outputString += Environment.NewLine + ArabicFixerTool.FixLine(strSplit[iteration]);
|
||||
iteration++;
|
||||
}
|
||||
}
|
||||
return outputString;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return ArabicFixerTool.FixLine(str);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Arabic Contextual forms General - Unicode
|
||||
/// </summary>
|
||||
internal enum IsolatedArabicLetters
|
||||
{
|
||||
Hamza = 0xFE80,
|
||||
Alef = 0xFE8D,
|
||||
AlefHamza = 0xFE83,
|
||||
WawHamza = 0xFE85,
|
||||
AlefMaksoor = 0xFE87,
|
||||
AlefMaksora = 0xFBFC,
|
||||
HamzaNabera = 0xFE89,
|
||||
Ba = 0xFE8F,
|
||||
Ta = 0xFE95,
|
||||
Tha2 = 0xFE99,
|
||||
Jeem = 0xFE9D,
|
||||
H7aa = 0xFEA1,
|
||||
Khaa2 = 0xFEA5,
|
||||
Dal = 0xFEA9,
|
||||
Thal = 0xFEAB,
|
||||
Ra2 = 0xFEAD,
|
||||
Zeen = 0xFEAF,
|
||||
Seen = 0xFEB1,
|
||||
Sheen = 0xFEB5,
|
||||
S9a = 0xFEB9,
|
||||
Dha = 0xFEBD,
|
||||
T6a = 0xFEC1,
|
||||
T6ha = 0xFEC5,
|
||||
Ain = 0xFEC9,
|
||||
Gain = 0xFECD,
|
||||
Fa = 0xFED1,
|
||||
Gaf = 0xFED5,
|
||||
Kaf = 0xFED9,
|
||||
Lam = 0xFEDD,
|
||||
Meem = 0xFEE1,
|
||||
Noon = 0xFEE5,
|
||||
Ha = 0xFEE9,
|
||||
Waw = 0xFEED,
|
||||
Ya = 0xFEF1,
|
||||
AlefMad = 0xFE81,
|
||||
TaMarboota = 0xFE93,
|
||||
PersianPe = 0xFB56, // Persian Letters;
|
||||
PersianChe = 0xFB7A,
|
||||
PersianZe = 0xFB8A,
|
||||
PersianGaf = 0xFB92,
|
||||
PersianGaf2 = 0xFB8E
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Arabic Contextual forms - Isolated
|
||||
/// </summary>
|
||||
internal enum GeneralArabicLetters
|
||||
{
|
||||
Hamza = 0x0621,
|
||||
Alef = 0x0627,
|
||||
AlefHamza = 0x0623,
|
||||
WawHamza = 0x0624,
|
||||
AlefMaksoor = 0x0625,
|
||||
AlefMagsora = 0x0649,
|
||||
HamzaNabera = 0x0626,
|
||||
Ba = 0x0628,
|
||||
Ta = 0x062A,
|
||||
Tha2 = 0x062B,
|
||||
Jeem = 0x062C,
|
||||
H7aa = 0x062D,
|
||||
Khaa2 = 0x062E,
|
||||
Dal = 0x062F,
|
||||
Thal = 0x0630,
|
||||
Ra2 = 0x0631,
|
||||
Zeen = 0x0632,
|
||||
Seen = 0x0633,
|
||||
Sheen = 0x0634,
|
||||
S9a = 0x0635,
|
||||
Dha = 0x0636,
|
||||
T6a = 0x0637,
|
||||
T6ha = 0x0638,
|
||||
Ain = 0x0639,
|
||||
Gain = 0x063A,
|
||||
Fa = 0x0641,
|
||||
Gaf = 0x0642,
|
||||
Kaf = 0x0643,
|
||||
Lam = 0x0644,
|
||||
Meem = 0x0645,
|
||||
Noon = 0x0646,
|
||||
Ha = 0x0647,
|
||||
Waw = 0x0648,
|
||||
Ya = 0x064A,
|
||||
AlefMad = 0x0622,
|
||||
TaMarboota = 0x0629,
|
||||
PersianPe = 0x067E, // Persian Letters;
|
||||
PersianChe = 0x0686,
|
||||
PersianZe = 0x0698,
|
||||
PersianGaf = 0x06AF,
|
||||
PersianGaf2 = 0x06A9
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Data Structure for conversion
|
||||
/// </summary>
|
||||
internal class ArabicMapping
|
||||
{
|
||||
public int from;
|
||||
public int to;
|
||||
public ArabicMapping(int from, int to)
|
||||
{
|
||||
this.from = from;
|
||||
this.to = to;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets up and creates the conversion table
|
||||
/// </summary>
|
||||
internal class ArabicTable
|
||||
{
|
||||
|
||||
private static List<ArabicMapping> mapList;
|
||||
private static ArabicTable arabicMapper;
|
||||
|
||||
/// <summary>
|
||||
/// Setting up the conversion table
|
||||
/// </summary>
|
||||
private ArabicTable()
|
||||
{
|
||||
mapList = new List<ArabicMapping>();
|
||||
|
||||
|
||||
|
||||
mapList.Add(new ArabicMapping((int)GeneralArabicLetters.Hamza, (int)IsolatedArabicLetters.Hamza));
|
||||
mapList.Add(new ArabicMapping((int)GeneralArabicLetters.Alef, (int)IsolatedArabicLetters.Alef));
|
||||
mapList.Add(new ArabicMapping((int)GeneralArabicLetters.AlefHamza, (int)IsolatedArabicLetters.AlefHamza));
|
||||
mapList.Add(new ArabicMapping((int)GeneralArabicLetters.WawHamza, (int)IsolatedArabicLetters.WawHamza));
|
||||
mapList.Add(new ArabicMapping((int)GeneralArabicLetters.AlefMaksoor, (int)IsolatedArabicLetters.AlefMaksoor));
|
||||
mapList.Add(new ArabicMapping((int)GeneralArabicLetters.AlefMagsora, (int)IsolatedArabicLetters.AlefMaksora));
|
||||
mapList.Add(new ArabicMapping((int)GeneralArabicLetters.HamzaNabera, (int)IsolatedArabicLetters.HamzaNabera));
|
||||
mapList.Add(new ArabicMapping((int)GeneralArabicLetters.Ba, (int)IsolatedArabicLetters.Ba));
|
||||
mapList.Add(new ArabicMapping((int)GeneralArabicLetters.Ta, (int)IsolatedArabicLetters.Ta));
|
||||
mapList.Add(new ArabicMapping((int)GeneralArabicLetters.Tha2, (int)IsolatedArabicLetters.Tha2));
|
||||
mapList.Add(new ArabicMapping((int)GeneralArabicLetters.Jeem, (int)IsolatedArabicLetters.Jeem));
|
||||
mapList.Add(new ArabicMapping((int)GeneralArabicLetters.H7aa, (int)IsolatedArabicLetters.H7aa));
|
||||
mapList.Add(new ArabicMapping((int)GeneralArabicLetters.Khaa2, (int)IsolatedArabicLetters.Khaa2));
|
||||
mapList.Add(new ArabicMapping((int)GeneralArabicLetters.Dal, (int)IsolatedArabicLetters.Dal));
|
||||
mapList.Add(new ArabicMapping((int)GeneralArabicLetters.Thal, (int)IsolatedArabicLetters.Thal));
|
||||
mapList.Add(new ArabicMapping((int)GeneralArabicLetters.Ra2, (int)IsolatedArabicLetters.Ra2));
|
||||
mapList.Add(new ArabicMapping((int)GeneralArabicLetters.Zeen, (int)IsolatedArabicLetters.Zeen));
|
||||
mapList.Add(new ArabicMapping((int)GeneralArabicLetters.Seen, (int)IsolatedArabicLetters.Seen));
|
||||
mapList.Add(new ArabicMapping((int)GeneralArabicLetters.Sheen, (int)IsolatedArabicLetters.Sheen));
|
||||
mapList.Add(new ArabicMapping((int)GeneralArabicLetters.S9a, (int)IsolatedArabicLetters.S9a));
|
||||
mapList.Add(new ArabicMapping((int)GeneralArabicLetters.Dha, (int)IsolatedArabicLetters.Dha));
|
||||
mapList.Add(new ArabicMapping((int)GeneralArabicLetters.T6a, (int)IsolatedArabicLetters.T6a));
|
||||
mapList.Add(new ArabicMapping((int)GeneralArabicLetters.T6ha, (int)IsolatedArabicLetters.T6ha));
|
||||
mapList.Add(new ArabicMapping((int)GeneralArabicLetters.Ain, (int)IsolatedArabicLetters.Ain));
|
||||
mapList.Add(new ArabicMapping((int)GeneralArabicLetters.Gain, (int)IsolatedArabicLetters.Gain));
|
||||
mapList.Add(new ArabicMapping((int)GeneralArabicLetters.Fa, (int)IsolatedArabicLetters.Fa));
|
||||
mapList.Add(new ArabicMapping((int)GeneralArabicLetters.Gaf, (int)IsolatedArabicLetters.Gaf));
|
||||
mapList.Add(new ArabicMapping((int)GeneralArabicLetters.Kaf, (int)IsolatedArabicLetters.Kaf));
|
||||
mapList.Add(new ArabicMapping((int)GeneralArabicLetters.Lam, (int)IsolatedArabicLetters.Lam));
|
||||
mapList.Add(new ArabicMapping((int)GeneralArabicLetters.Meem, (int)IsolatedArabicLetters.Meem));
|
||||
mapList.Add(new ArabicMapping((int)GeneralArabicLetters.Noon, (int)IsolatedArabicLetters.Noon));
|
||||
mapList.Add(new ArabicMapping((int)GeneralArabicLetters.Ha, (int)IsolatedArabicLetters.Ha));
|
||||
mapList.Add(new ArabicMapping((int)GeneralArabicLetters.Waw, (int)IsolatedArabicLetters.Waw));
|
||||
mapList.Add(new ArabicMapping((int)GeneralArabicLetters.Ya, (int)IsolatedArabicLetters.Ya));
|
||||
mapList.Add(new ArabicMapping((int)GeneralArabicLetters.AlefMad, (int)IsolatedArabicLetters.AlefMad));
|
||||
mapList.Add(new ArabicMapping((int)GeneralArabicLetters.TaMarboota, (int)IsolatedArabicLetters.TaMarboota));
|
||||
mapList.Add(new ArabicMapping((int)GeneralArabicLetters.PersianPe, (int)IsolatedArabicLetters.PersianPe)); // Persian Letters;
|
||||
mapList.Add(new ArabicMapping((int)GeneralArabicLetters.PersianChe, (int)IsolatedArabicLetters.PersianChe));
|
||||
mapList.Add(new ArabicMapping((int)GeneralArabicLetters.PersianZe, (int)IsolatedArabicLetters.PersianZe));
|
||||
mapList.Add(new ArabicMapping((int)GeneralArabicLetters.PersianGaf, (int)IsolatedArabicLetters.PersianGaf));
|
||||
mapList.Add(new ArabicMapping((int)GeneralArabicLetters.PersianGaf2, (int)IsolatedArabicLetters.PersianGaf2));
|
||||
|
||||
|
||||
|
||||
|
||||
//for (int i = 0; i < generalArabic.Length; i++)
|
||||
// mapList.Add(new ArabicMapping((int)generalArabic.GetValue(i), (int)isolatedArabic.GetValue(i))); // I
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Singleton design pattern, Get the mapper. If it was not created before, create it.
|
||||
/// </summary>
|
||||
internal static ArabicTable ArabicMapper
|
||||
{
|
||||
get
|
||||
{
|
||||
if (arabicMapper == null)
|
||||
arabicMapper = new ArabicTable();
|
||||
return arabicMapper;
|
||||
}
|
||||
}
|
||||
|
||||
internal int Convert(int toBeConverted)
|
||||
{
|
||||
|
||||
foreach (ArabicMapping arabicMap in mapList)
|
||||
if (arabicMap.from == toBeConverted)
|
||||
{
|
||||
return arabicMap.to;
|
||||
}
|
||||
return toBeConverted;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
internal class TashkeelLocation
|
||||
{
|
||||
public char tashkeel;
|
||||
public int position;
|
||||
public TashkeelLocation(char tashkeel, int position)
|
||||
{
|
||||
this.tashkeel = tashkeel;
|
||||
this.position = position;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
internal class ArabicFixerTool
|
||||
{
|
||||
internal static bool showTashkeel = true;
|
||||
internal static bool useHinduNumbers = false;
|
||||
|
||||
|
||||
internal static string RemoveTashkeel(string str, out List<TashkeelLocation> tashkeelLocation)
|
||||
{
|
||||
tashkeelLocation = new List<TashkeelLocation>();
|
||||
char[] letters = str.ToCharArray();
|
||||
|
||||
int index = 0;
|
||||
for (int i = 0; i < letters.Length; i++) {
|
||||
if (letters [i] == (char)0x064B) { // Tanween Fatha
|
||||
tashkeelLocation.Add (new TashkeelLocation ((char)0x064B, i));
|
||||
index++;
|
||||
} else if (letters [i] == (char)0x064C) { // DAMMATAN
|
||||
tashkeelLocation.Add (new TashkeelLocation ((char)0x064C, i));
|
||||
index++;
|
||||
} else if (letters [i] == (char)0x064D){ // KASRATAN
|
||||
tashkeelLocation.Add (new TashkeelLocation ((char)0x064D, i));
|
||||
index++;
|
||||
}else if (letters [i] == (char)0x064E) { // FATHA
|
||||
if(index > 0)
|
||||
{
|
||||
if(tashkeelLocation[index-1].tashkeel == (char)0x0651 ) // SHADDA
|
||||
{
|
||||
tashkeelLocation [index - 1].tashkeel = (char)0xFC60; // Shadda With Fatha
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
tashkeelLocation.Add (new TashkeelLocation ((char)0x064E, i));
|
||||
index++;
|
||||
} else if (letters [i] == (char)0x064F) { // DAMMA
|
||||
if (index > 0) {
|
||||
if (tashkeelLocation [index - 1].tashkeel == (char)0x0651) { // SHADDA
|
||||
tashkeelLocation [index - 1].tashkeel = (char)0xFC61; // Shadda With DAMMA
|
||||
continue;
|
||||
}
|
||||
}
|
||||
tashkeelLocation.Add (new TashkeelLocation ((char)0x064F, i));
|
||||
index++;
|
||||
} else if (letters [i] == (char)0x0650) { // KASRA
|
||||
if (index > 0) {
|
||||
if (tashkeelLocation [index - 1].tashkeel == (char)0x0651) { // SHADDA
|
||||
tashkeelLocation [index - 1].tashkeel = (char)0xFC62; // Shadda With KASRA
|
||||
continue;
|
||||
}
|
||||
}
|
||||
tashkeelLocation.Add (new TashkeelLocation ((char)0x0650, i));
|
||||
index++;
|
||||
} else if (letters [i] == (char)0x0651) { // SHADDA
|
||||
if(index > 0)
|
||||
{
|
||||
if(tashkeelLocation[index-1].tashkeel == (char)0x064E ) // FATHA
|
||||
{
|
||||
tashkeelLocation [index - 1].tashkeel = (char)0xFC60; // Shadda With Fatha
|
||||
continue;
|
||||
}
|
||||
|
||||
if(tashkeelLocation[index-1].tashkeel == (char)0x064F ) // DAMMA
|
||||
{
|
||||
tashkeelLocation [index - 1].tashkeel = (char)0xFC61; // Shadda With DAMMA
|
||||
continue;
|
||||
}
|
||||
|
||||
if(tashkeelLocation[index-1].tashkeel == (char)0x0650 ) // KASRA
|
||||
{
|
||||
tashkeelLocation [index - 1].tashkeel = (char)0xFC62; // Shadda With KASRA
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
tashkeelLocation.Add (new TashkeelLocation ((char)0x0651, i));
|
||||
index++;
|
||||
} else if (letters [i] == (char)0x0652) { // SUKUN
|
||||
tashkeelLocation.Add (new TashkeelLocation ((char)0x0652, i));
|
||||
index++;
|
||||
} else if (letters [i] == (char)0x0653) { // MADDAH ABOVE
|
||||
tashkeelLocation.Add (new TashkeelLocation ((char)0x0653, i));
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
string[] split = str.Split(new char[]{(char)0x064B,(char)0x064C,(char)0x064D,
|
||||
(char)0x064E,(char)0x064F,(char)0x0650,
|
||||
|
||||
(char)0x0651,(char)0x0652,(char)0x0653,(char)0xFC60,(char)0xFC61,(char)0xFC62});
|
||||
str = "";
|
||||
|
||||
foreach(string s in split)
|
||||
{
|
||||
str += s;
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
internal static char[] ReturnTashkeel(char[] letters, List<TashkeelLocation> tashkeelLocation)
|
||||
{
|
||||
char[] lettersWithTashkeel = new char[letters.Length + tashkeelLocation.Count];
|
||||
|
||||
int letterWithTashkeelTracker = 0;
|
||||
for(int i = 0; i<letters.Length; i++)
|
||||
{
|
||||
lettersWithTashkeel[letterWithTashkeelTracker] = letters[i];
|
||||
letterWithTashkeelTracker++;
|
||||
foreach(TashkeelLocation hLocation in tashkeelLocation)
|
||||
{
|
||||
if(hLocation.position == letterWithTashkeelTracker)
|
||||
{
|
||||
lettersWithTashkeel[letterWithTashkeelTracker] = hLocation.tashkeel;
|
||||
letterWithTashkeelTracker++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return lettersWithTashkeel;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts a string to a form in which the sting will be displayed correctly for arabic text.
|
||||
/// </summary>
|
||||
/// <param name="str">String to be converted. Example: "Aaa"</param>
|
||||
/// <returns>Converted string. Example: "aa aaa A" without the spaces.</returns>
|
||||
internal static string FixLine(string str)
|
||||
{
|
||||
string test = "";
|
||||
|
||||
List<TashkeelLocation> tashkeelLocation;
|
||||
|
||||
string originString = RemoveTashkeel(str, out tashkeelLocation);
|
||||
|
||||
char[] lettersOrigin = originString.ToCharArray();
|
||||
char[] lettersFinal = originString.ToCharArray();
|
||||
|
||||
|
||||
|
||||
for (int i = 0; i < lettersOrigin.Length; i++)
|
||||
{
|
||||
lettersOrigin[i] = (char)ArabicTable.ArabicMapper.Convert(lettersOrigin[i]);
|
||||
}
|
||||
|
||||
for (int i = 0; i < lettersOrigin.Length; i++)
|
||||
{
|
||||
bool skip = false;
|
||||
|
||||
|
||||
//lettersOrigin[i] = (char)ArabicTable.ArabicMapper.Convert(lettersOrigin[i]);
|
||||
|
||||
|
||||
// For special Lam Letter connections.
|
||||
if (lettersOrigin[i] == (char)IsolatedArabicLetters.Lam)
|
||||
{
|
||||
|
||||
if (i < lettersOrigin.Length - 1)
|
||||
{
|
||||
//lettersOrigin[i + 1] = (char)ArabicTable.ArabicMapper.Convert(lettersOrigin[i + 1]);
|
||||
if ((lettersOrigin[i + 1] == (char)IsolatedArabicLetters.AlefMaksoor))
|
||||
{
|
||||
lettersOrigin[i] = (char)0xFEF7;
|
||||
lettersFinal[i + 1] = (char)0xFFFF;
|
||||
skip = true;
|
||||
}
|
||||
else if ((lettersOrigin[i + 1] == (char)IsolatedArabicLetters.Alef))
|
||||
{
|
||||
lettersOrigin[i] = (char)0xFEF9;
|
||||
lettersFinal[i + 1] = (char)0xFFFF;
|
||||
skip = true;
|
||||
}
|
||||
else if ((lettersOrigin[i + 1] == (char)IsolatedArabicLetters.AlefHamza))
|
||||
{
|
||||
lettersOrigin[i] = (char)0xFEF5;
|
||||
lettersFinal[i + 1] = (char)0xFFFF;
|
||||
skip = true;
|
||||
}
|
||||
else if ((lettersOrigin[i + 1] == (char)IsolatedArabicLetters.AlefMad))
|
||||
{
|
||||
lettersOrigin[i] = (char)0xFEF3;
|
||||
lettersFinal[i + 1] = (char)0xFFFF;
|
||||
skip = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (!IsIgnoredCharacter(lettersOrigin[i]))
|
||||
{
|
||||
if (IsMiddleLetter(lettersOrigin, i))
|
||||
lettersFinal[i] = (char)(lettersOrigin[i] + 3);
|
||||
else if (IsFinishingLetter(lettersOrigin, i))
|
||||
lettersFinal[i] = (char)(lettersOrigin[i] + 1);
|
||||
else if (IsLeadingLetter(lettersOrigin, i))
|
||||
lettersFinal[i] = (char)(lettersOrigin[i] + 2);
|
||||
}
|
||||
|
||||
//string strOut = String.Format(@"\x{0:x4}", (ushort)lettersOrigin[i]);
|
||||
//UnityEngine.Debug.Log(strOut);
|
||||
|
||||
//strOut = String.Format(@"\x{0:x4}", (ushort)lettersFinal[i]);
|
||||
//UnityEngine.Debug.Log(strOut);
|
||||
|
||||
test += Convert.ToString((int)lettersOrigin[i], 16) + " ";
|
||||
if (skip)
|
||||
i++;
|
||||
|
||||
|
||||
//chaning numbers to hindu
|
||||
if(useHinduNumbers){
|
||||
if(lettersOrigin[i] == (char)0x0030)
|
||||
lettersFinal[i] = (char)0x0660;
|
||||
else if(lettersOrigin[i] == (char)0x0031)
|
||||
lettersFinal[i] = (char)0x0661;
|
||||
else if(lettersOrigin[i] == (char)0x0032)
|
||||
lettersFinal[i] = (char)0x0662;
|
||||
else if(lettersOrigin[i] == (char)0x0033)
|
||||
lettersFinal[i] = (char)0x0663;
|
||||
else if(lettersOrigin[i] == (char)0x0034)
|
||||
lettersFinal[i] = (char)0x0664;
|
||||
else if(lettersOrigin[i] == (char)0x0035)
|
||||
lettersFinal[i] = (char)0x0665;
|
||||
else if(lettersOrigin[i] == (char)0x0036)
|
||||
lettersFinal[i] = (char)0x0666;
|
||||
else if(lettersOrigin[i] == (char)0x0037)
|
||||
lettersFinal[i] = (char)0x0667;
|
||||
else if(lettersOrigin[i] == (char)0x0038)
|
||||
lettersFinal[i] = (char)0x0668;
|
||||
else if(lettersOrigin[i] == (char)0x0039)
|
||||
lettersFinal[i] = (char)0x0669;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//Return the Tashkeel to their places.
|
||||
if(showTashkeel)
|
||||
lettersFinal = ReturnTashkeel(lettersFinal, tashkeelLocation);
|
||||
|
||||
|
||||
List<char> list = new List<char>();
|
||||
|
||||
List<char> numberList = new List<char>();
|
||||
|
||||
for (int i = lettersFinal.Length - 1; i >= 0; i--)
|
||||
{
|
||||
|
||||
|
||||
// if (lettersFinal[i] == '(')
|
||||
// numberList.Add(')');
|
||||
// else if (lettersFinal[i] == ')')
|
||||
// numberList.Add('(');
|
||||
// else if (lettersFinal[i] == '<')
|
||||
// numberList.Add('>');
|
||||
// else if (lettersFinal[i] == '>')
|
||||
// numberList.Add('<');
|
||||
// else
|
||||
if (char.IsPunctuation(lettersFinal[i]) && i>0 && i < lettersFinal.Length-1 &&
|
||||
(char.IsPunctuation(lettersFinal[i-1]) || char.IsPunctuation(lettersFinal[i+1])))
|
||||
{
|
||||
if (lettersFinal[i] == '(')
|
||||
list.Add(')');
|
||||
else if (lettersFinal[i] == ')')
|
||||
list.Add('(');
|
||||
else if (lettersFinal[i] == '<')
|
||||
list.Add('>');
|
||||
else if (lettersFinal[i] == '>')
|
||||
list.Add('<');
|
||||
else if (lettersFinal[i] == '[')
|
||||
list.Add(']');
|
||||
else if (lettersFinal[i] == ']')
|
||||
list.Add('[');
|
||||
else if (lettersFinal[i] != 0xFFFF)
|
||||
list.Add(lettersFinal[i]);
|
||||
}
|
||||
// For cases where english words and arabic are mixed. This allows for using arabic, english and numbers in one sentence.
|
||||
else if(lettersFinal[i] == ' ' && i > 0 && i < lettersFinal.Length-1 &&
|
||||
(char.IsLower(lettersFinal[i-1]) || char.IsUpper(lettersFinal[i-1]) || char.IsNumber(lettersFinal[i-1])) &&
|
||||
(char.IsLower(lettersFinal[i+1]) || char.IsUpper(lettersFinal[i+1]) ||char.IsNumber(lettersFinal[i+1])))
|
||||
|
||||
{
|
||||
numberList.Add(lettersFinal[i]);
|
||||
}
|
||||
|
||||
else if (char.IsNumber(lettersFinal[i]) || char.IsLower(lettersFinal[i]) ||
|
||||
char.IsUpper(lettersFinal[i]) || char.IsSymbol(lettersFinal[i]) ||
|
||||
char.IsPunctuation(lettersFinal[i]))// || lettersFinal[i] == '^') //)
|
||||
{
|
||||
|
||||
if (lettersFinal[i] == '(')
|
||||
numberList.Add(')');
|
||||
else if (lettersFinal[i] == ')')
|
||||
numberList.Add('(');
|
||||
else if (lettersFinal[i] == '<')
|
||||
numberList.Add('>');
|
||||
else if (lettersFinal[i] == '>')
|
||||
numberList.Add('<');
|
||||
else if (lettersFinal[i] == '[')
|
||||
list.Add(']');
|
||||
else if (lettersFinal[i] == ']')
|
||||
list.Add('[');
|
||||
else
|
||||
numberList.Add(lettersFinal[i]);
|
||||
}
|
||||
else if( (lettersFinal[i] >= (char)0xD800 && lettersFinal[i] <= (char)0xDBFF) ||
|
||||
(lettersFinal[i] >= (char)0xDC00 && lettersFinal[i] <= (char)0xDFFF))
|
||||
{
|
||||
numberList.Add(lettersFinal[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (numberList.Count > 0)
|
||||
{
|
||||
for (int j = 0; j < numberList.Count; j++)
|
||||
list.Add(numberList[numberList.Count - 1 - j]);
|
||||
numberList.Clear();
|
||||
}
|
||||
if (lettersFinal[i] != 0xFFFF)
|
||||
list.Add(lettersFinal[i]);
|
||||
|
||||
}
|
||||
}
|
||||
if (numberList.Count > 0)
|
||||
{
|
||||
for (int j = 0; j < numberList.Count; j++)
|
||||
list.Add(numberList[numberList.Count - 1 - j]);
|
||||
numberList.Clear();
|
||||
}
|
||||
|
||||
// Moving letters from a list to an array.
|
||||
lettersFinal = new char[list.Count];
|
||||
for (int i = 0; i < lettersFinal.Length; i++)
|
||||
lettersFinal[i] = list[i];
|
||||
|
||||
|
||||
str = new string(lettersFinal);
|
||||
return str;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// English letters, numbers and punctuation characters are ignored. This checks if the ch is an ignored character.
|
||||
/// </summary>
|
||||
/// <param name="ch">The character to be checked for skipping</param>
|
||||
/// <returns>True if the character should be ignored, false if it should not be ignored.</returns>
|
||||
internal static bool IsIgnoredCharacter(char ch)
|
||||
{
|
||||
bool isPunctuation = char.IsPunctuation(ch);
|
||||
bool isNumber = char.IsNumber(ch);
|
||||
bool isLower = char.IsLower(ch);
|
||||
bool isUpper = char.IsUpper(ch);
|
||||
bool isSymbol = char.IsSymbol(ch);
|
||||
bool isPersianCharacter = ch == (char)0xFB56 || ch == (char)0xFB7A || ch == (char)0xFB8A || ch == (char)0xFB92 || ch == (char)0xFB8E;
|
||||
bool isPresentationFormB = (ch <= (char)0xFEFF && ch >= (char)0xFE70);
|
||||
bool isAcceptableCharacter = isPresentationFormB || isPersianCharacter || ch == (char)0xFBFC;
|
||||
|
||||
|
||||
|
||||
return isPunctuation ||
|
||||
isNumber ||
|
||||
isLower ||
|
||||
isUpper ||
|
||||
isSymbol ||
|
||||
!isAcceptableCharacter ||
|
||||
ch == 'a' || ch == '>' || ch == '<' || ch == (char)0x061B;
|
||||
|
||||
// return char.IsPunctuation(ch) || char.IsNumber(ch) || ch == 'a' || ch == '>' || ch == '<' ||
|
||||
// char.IsLower(ch) || char.IsUpper(ch) || ch == (char)0x061B || char.IsSymbol(ch)
|
||||
// || !(ch <= (char)0xFEFF && ch >= (char)0xFE70) // Presentation Form B
|
||||
// || ch == (char)0xFB56 || ch == (char)0xFB7A || ch == (char)0xFB8A || ch == (char)0xFB92; // Persian Characters
|
||||
|
||||
// PersianPe = 0xFB56,
|
||||
// PersianChe = 0xFB7A,
|
||||
// PersianZe = 0xFB8A,
|
||||
// PersianGaf = 0xFB92
|
||||
//lettersOrigin[i] <= (char)0xFEFF && lettersOrigin[i] >= (char)0xFE70
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the letter at index value is a leading character in Arabic or not.
|
||||
/// </summary>
|
||||
/// <param name="letters">The whole word that contains the character to be checked</param>
|
||||
/// <param name="index">The index of the character to be checked</param>
|
||||
/// <returns>True if the character at index is a leading character, else, returns false</returns>
|
||||
internal static bool IsLeadingLetter(char[] letters, int index)
|
||||
{
|
||||
|
||||
bool lettersThatCannotBeBeforeALeadingLetter = index == 0
|
||||
|| letters[index - 1] == ' '
|
||||
|| letters[index - 1] == '*' // ??? Remove?
|
||||
|| letters[index - 1] == 'A' // ??? Remove?
|
||||
|| char.IsPunctuation(letters[index - 1])
|
||||
|| letters[index - 1] == '>'
|
||||
|| letters[index - 1] == '<'
|
||||
|| letters[index - 1] == (int)IsolatedArabicLetters.Alef
|
||||
|| letters[index - 1] == (int)IsolatedArabicLetters.Dal
|
||||
|| letters[index - 1] == (int)IsolatedArabicLetters.Thal
|
||||
|| letters[index - 1] == (int)IsolatedArabicLetters.Ra2
|
||||
|| letters[index - 1] == (int)IsolatedArabicLetters.Zeen
|
||||
|| letters[index - 1] == (int)IsolatedArabicLetters.PersianZe
|
||||
//|| letters[index - 1] == (int)IsolatedArabicLetters.AlefMaksora
|
||||
|| letters[index - 1] == (int)IsolatedArabicLetters.Waw
|
||||
|| letters[index - 1] == (int)IsolatedArabicLetters.AlefMad
|
||||
|| letters[index - 1] == (int)IsolatedArabicLetters.AlefHamza
|
||||
|| letters[index - 1] == (int)IsolatedArabicLetters.Hamza
|
||||
|| letters[index - 1] == (int)IsolatedArabicLetters.AlefMaksoor
|
||||
|| letters[index - 1] == (int)IsolatedArabicLetters.WawHamza;
|
||||
|
||||
bool lettersThatCannotBeALeadingLetter = letters[index] != ' '
|
||||
&& letters[index] != (int)IsolatedArabicLetters.Dal
|
||||
&& letters[index] != (int)IsolatedArabicLetters.Thal
|
||||
&& letters[index] != (int)IsolatedArabicLetters.Ra2
|
||||
&& letters[index] != (int)IsolatedArabicLetters.Zeen
|
||||
&& letters[index] != (int)IsolatedArabicLetters.PersianZe
|
||||
&& letters[index] != (int)IsolatedArabicLetters.Alef
|
||||
&& letters[index] != (int)IsolatedArabicLetters.AlefHamza
|
||||
&& letters[index] != (int)IsolatedArabicLetters.AlefMaksoor
|
||||
&& letters[index] != (int)IsolatedArabicLetters.AlefMad
|
||||
&& letters[index] != (int)IsolatedArabicLetters.WawHamza
|
||||
&& letters[index] != (int)IsolatedArabicLetters.Waw
|
||||
&& letters[index] != (int)IsolatedArabicLetters.Hamza;
|
||||
|
||||
bool lettersThatCannotBeAfterLeadingLetter = index < letters.Length - 1
|
||||
&& letters[index + 1] != ' '
|
||||
&& !char.IsPunctuation(letters[index + 1] )
|
||||
&& !char.IsNumber(letters[index + 1])
|
||||
&& !char.IsSymbol(letters[index + 1])
|
||||
&& !char.IsLower(letters[index + 1])
|
||||
&& !char.IsUpper(letters[index + 1])
|
||||
&& letters[index + 1] != (int)IsolatedArabicLetters.Hamza;
|
||||
|
||||
if(lettersThatCannotBeBeforeALeadingLetter && lettersThatCannotBeALeadingLetter && lettersThatCannotBeAfterLeadingLetter)
|
||||
|
||||
// if ((index == 0 || letters[index - 1] == ' ' || letters[index - 1] == '*' || letters[index - 1] == 'A' || char.IsPunctuation(letters[index - 1])
|
||||
// || letters[index - 1] == '>' || letters[index - 1] == '<'
|
||||
// || letters[index - 1] == (int)IsolatedArabicLetters.Alef
|
||||
// || letters[index - 1] == (int)IsolatedArabicLetters.Dal || letters[index - 1] == (int)IsolatedArabicLetters.Thal
|
||||
// || letters[index - 1] == (int)IsolatedArabicLetters.Ra2
|
||||
// || letters[index - 1] == (int)IsolatedArabicLetters.Zeen || letters[index - 1] == (int)IsolatedArabicLetters.PersianZe
|
||||
// || letters[index - 1] == (int)IsolatedArabicLetters.AlefMaksora || letters[index - 1] == (int)IsolatedArabicLetters.Waw
|
||||
// || letters[index - 1] == (int)IsolatedArabicLetters.AlefMad || letters[index - 1] == (int)IsolatedArabicLetters.AlefHamza
|
||||
// || letters[index - 1] == (int)IsolatedArabicLetters.AlefMaksoor || letters[index - 1] == (int)IsolatedArabicLetters.WawHamza)
|
||||
// && letters[index] != ' ' && letters[index] != (int)IsolatedArabicLetters.Dal
|
||||
// && letters[index] != (int)IsolatedArabicLetters.Thal
|
||||
// && letters[index] != (int)IsolatedArabicLetters.Ra2
|
||||
// && letters[index] != (int)IsolatedArabicLetters.Zeen && letters[index] != (int)IsolatedArabicLetters.PersianZe
|
||||
// && letters[index] != (int)IsolatedArabicLetters.Alef && letters[index] != (int)IsolatedArabicLetters.AlefHamza
|
||||
// && letters[index] != (int)IsolatedArabicLetters.AlefMaksoor
|
||||
// && letters[index] != (int)IsolatedArabicLetters.AlefMad
|
||||
// && letters[index] != (int)IsolatedArabicLetters.WawHamza
|
||||
// && letters[index] != (int)IsolatedArabicLetters.Waw
|
||||
// && letters[index] != (int)IsolatedArabicLetters.Hamza
|
||||
// && index < letters.Length - 1 && letters[index + 1] != ' ' && !char.IsPunctuation(letters[index + 1] ) && !char.IsNumber(letters[index + 1])
|
||||
// && letters[index + 1] != (int)IsolatedArabicLetters.Hamza )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the letter at index value is a finishing character in Arabic or not.
|
||||
/// </summary>
|
||||
/// <param name="letters">The whole word that contains the character to be checked</param>
|
||||
/// <param name="index">The index of the character to be checked</param>
|
||||
/// <returns>True if the character at index is a finishing character, else, returns false</returns>
|
||||
internal static bool IsFinishingLetter(char[] letters, int index)
|
||||
{
|
||||
bool indexZero = index != 0;
|
||||
bool lettersThatCannotBeBeforeAFinishingLetter = (index == 0) ? false :
|
||||
letters[index - 1] != ' '
|
||||
// && char.IsDigit(letters[index-1])
|
||||
// && char.IsLower(letters[index-1])
|
||||
// && char.IsUpper(letters[index-1])
|
||||
// && char.IsNumber(letters[index-1])
|
||||
// && char.IsWhiteSpace(letters[index-1])
|
||||
// && char.IsPunctuation(letters[index-1])
|
||||
// && char.IsSymbol(letters[index-1])
|
||||
|
||||
&& letters[index - 1] != (int)IsolatedArabicLetters.Dal
|
||||
&& letters[index - 1] != (int)IsolatedArabicLetters.Thal
|
||||
&& letters[index - 1] != (int)IsolatedArabicLetters.Ra2
|
||||
&& letters[index - 1] != (int)IsolatedArabicLetters.Zeen
|
||||
&& letters[index - 1] != (int)IsolatedArabicLetters.PersianZe
|
||||
//&& letters[index - 1] != (int)IsolatedArabicLetters.AlefMaksora
|
||||
&& letters[index - 1] != (int)IsolatedArabicLetters.Waw
|
||||
&& letters[index - 1] != (int)IsolatedArabicLetters.Alef
|
||||
&& letters[index - 1] != (int)IsolatedArabicLetters.AlefMad
|
||||
&& letters[index - 1] != (int)IsolatedArabicLetters.AlefHamza
|
||||
&& letters[index - 1] != (int)IsolatedArabicLetters.AlefMaksoor
|
||||
&& letters[index - 1] != (int)IsolatedArabicLetters.WawHamza
|
||||
&& letters[index - 1] != (int)IsolatedArabicLetters.Hamza
|
||||
|
||||
|
||||
|
||||
&& !char.IsPunctuation(letters[index - 1])
|
||||
&& letters[index - 1] != '>'
|
||||
&& letters[index - 1] != '<';
|
||||
|
||||
|
||||
bool lettersThatCannotBeFinishingLetters = letters[index] != ' ' && letters[index] != (int)IsolatedArabicLetters.Hamza;
|
||||
|
||||
|
||||
|
||||
|
||||
if(lettersThatCannotBeBeforeAFinishingLetter && lettersThatCannotBeFinishingLetters)
|
||||
|
||||
// if (index != 0 && letters[index - 1] != ' ' && letters[index - 1] != '*' && letters[index - 1] != 'A'
|
||||
// && letters[index - 1] != (int)IsolatedArabicLetters.Dal && letters[index - 1] != (int)IsolatedArabicLetters.Thal
|
||||
// && letters[index - 1] != (int)IsolatedArabicLetters.Ra2
|
||||
// && letters[index - 1] != (int)IsolatedArabicLetters.Zeen && letters[index - 1] != (int)IsolatedArabicLetters.PersianZe
|
||||
// && letters[index - 1] != (int)IsolatedArabicLetters.AlefMaksora && letters[index - 1] != (int)IsolatedArabicLetters.Waw
|
||||
// && letters[index - 1] != (int)IsolatedArabicLetters.Alef && letters[index - 1] != (int)IsolatedArabicLetters.AlefMad
|
||||
// && letters[index - 1] != (int)IsolatedArabicLetters.AlefHamza && letters[index - 1] != (int)IsolatedArabicLetters.AlefMaksoor
|
||||
// && letters[index - 1] != (int)IsolatedArabicLetters.WawHamza && letters[index - 1] != (int)IsolatedArabicLetters.Hamza
|
||||
// && !char.IsPunctuation(letters[index - 1]) && letters[index - 1] != '>' && letters[index - 1] != '<'
|
||||
// && letters[index] != ' ' && index < letters.Length
|
||||
// && letters[index] != (int)IsolatedArabicLetters.Hamza)
|
||||
{
|
||||
//try
|
||||
//{
|
||||
// if (char.IsPunctuation(letters[index + 1]))
|
||||
// return true;
|
||||
// else
|
||||
// return false;
|
||||
//}
|
||||
//catch (Exception e)
|
||||
//{
|
||||
// return false;
|
||||
//}
|
||||
|
||||
return true;
|
||||
}
|
||||
//return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the letter at index value is a middle character in Arabic or not.
|
||||
/// </summary>
|
||||
/// <param name="letters">The whole word that contains the character to be checked</param>
|
||||
/// <param name="index">The index of the character to be checked</param>
|
||||
/// <returns>True if the character at index is a middle character, else, returns false</returns>
|
||||
internal static bool IsMiddleLetter(char[] letters, int index)
|
||||
{
|
||||
bool lettersThatCannotBeMiddleLetters = (index == 0) ? false :
|
||||
letters[index] != (int)IsolatedArabicLetters.Alef
|
||||
&& letters[index] != (int)IsolatedArabicLetters.Dal
|
||||
&& letters[index] != (int)IsolatedArabicLetters.Thal
|
||||
&& letters[index] != (int)IsolatedArabicLetters.Ra2
|
||||
&& letters[index] != (int)IsolatedArabicLetters.Zeen
|
||||
&& letters[index] != (int)IsolatedArabicLetters.PersianZe
|
||||
//&& letters[index] != (int)IsolatedArabicLetters.AlefMaksora
|
||||
&& letters[index] != (int)IsolatedArabicLetters.Waw
|
||||
&& letters[index] != (int)IsolatedArabicLetters.AlefMad
|
||||
&& letters[index] != (int)IsolatedArabicLetters.AlefHamza
|
||||
&& letters[index] != (int)IsolatedArabicLetters.AlefMaksoor
|
||||
&& letters[index] != (int)IsolatedArabicLetters.WawHamza
|
||||
&& letters[index] != (int)IsolatedArabicLetters.Hamza;
|
||||
|
||||
bool lettersThatCannotBeBeforeMiddleCharacters = (index == 0) ? false :
|
||||
letters[index - 1] != (int)IsolatedArabicLetters.Alef
|
||||
&& letters[index - 1] != (int)IsolatedArabicLetters.Dal
|
||||
&& letters[index - 1] != (int)IsolatedArabicLetters.Thal
|
||||
&& letters[index - 1] != (int)IsolatedArabicLetters.Ra2
|
||||
&& letters[index - 1] != (int)IsolatedArabicLetters.Zeen
|
||||
&& letters[index - 1] != (int)IsolatedArabicLetters.PersianZe
|
||||
//&& letters[index - 1] != (int)IsolatedArabicLetters.AlefMaksora
|
||||
&& letters[index - 1] != (int)IsolatedArabicLetters.Waw
|
||||
&& letters[index - 1] != (int)IsolatedArabicLetters.AlefMad
|
||||
&& letters[index - 1] != (int)IsolatedArabicLetters.AlefHamza
|
||||
&& letters[index - 1] != (int)IsolatedArabicLetters.AlefMaksoor
|
||||
&& letters[index - 1] != (int)IsolatedArabicLetters.WawHamza
|
||||
&& letters[index - 1] != (int)IsolatedArabicLetters.Hamza
|
||||
&& !char.IsPunctuation(letters[index - 1])
|
||||
&& letters[index - 1] != '>'
|
||||
&& letters[index - 1] != '<'
|
||||
&& letters[index - 1] != ' '
|
||||
&& letters[index - 1] != '*';
|
||||
|
||||
bool lettersThatCannotBeAfterMiddleCharacters = (index >= letters.Length - 1) ? false :
|
||||
letters[index + 1] != ' '
|
||||
&& letters[index + 1] != '\r'
|
||||
&& letters[index + 1] != (int)IsolatedArabicLetters.Hamza
|
||||
&& !char.IsNumber(letters[index + 1])
|
||||
&& !char.IsSymbol(letters[index + 1])
|
||||
&& !char.IsPunctuation(letters[index + 1]);
|
||||
if(lettersThatCannotBeAfterMiddleCharacters && lettersThatCannotBeBeforeMiddleCharacters && lettersThatCannotBeMiddleLetters)
|
||||
|
||||
// if (index != 0 && letters[index] != ' '
|
||||
// && letters[index] != (int)IsolatedArabicLetters.Alef && letters[index] != (int)IsolatedArabicLetters.Dal
|
||||
// && letters[index] != (int)IsolatedArabicLetters.Thal && letters[index] != (int)IsolatedArabicLetters.Ra2
|
||||
// && letters[index] != (int)IsolatedArabicLetters.Zeen && letters[index] != (int)IsolatedArabicLetters.PersianZe
|
||||
// && letters[index] != (int)IsolatedArabicLetters.AlefMaksora
|
||||
// && letters[index] != (int)IsolatedArabicLetters.Waw && letters[index] != (int)IsolatedArabicLetters.AlefMad
|
||||
// && letters[index] != (int)IsolatedArabicLetters.AlefHamza && letters[index] != (int)IsolatedArabicLetters.AlefMaksoor
|
||||
// && letters[index] != (int)IsolatedArabicLetters.WawHamza && letters[index] != (int)IsolatedArabicLetters.Hamza
|
||||
// && letters[index - 1] != (int)IsolatedArabicLetters.Alef && letters[index - 1] != (int)IsolatedArabicLetters.Dal
|
||||
// && letters[index - 1] != (int)IsolatedArabicLetters.Thal && letters[index - 1] != (int)IsolatedArabicLetters.Ra2
|
||||
// && letters[index - 1] != (int)IsolatedArabicLetters.Zeen && letters[index - 1] != (int)IsolatedArabicLetters.PersianZe
|
||||
// && letters[index - 1] != (int)IsolatedArabicLetters.AlefMaksora
|
||||
// && letters[index - 1] != (int)IsolatedArabicLetters.Waw && letters[index - 1] != (int)IsolatedArabicLetters.AlefMad
|
||||
// && letters[index - 1] != (int)IsolatedArabicLetters.AlefHamza && letters[index - 1] != (int)IsolatedArabicLetters.AlefMaksoor
|
||||
// && letters[index - 1] != (int)IsolatedArabicLetters.WawHamza && letters[index - 1] != (int)IsolatedArabicLetters.Hamza
|
||||
// && letters[index - 1] != '>' && letters[index - 1] != '<'
|
||||
// && letters[index - 1] != ' ' && letters[index - 1] != '*' && !char.IsPunctuation(letters[index - 1])
|
||||
// && index < letters.Length - 1 && letters[index + 1] != ' ' && letters[index + 1] != '\r' && letters[index + 1] != 'A'
|
||||
// && letters[index + 1] != '>' && letters[index + 1] != '>' && letters[index + 1] != (int)IsolatedArabicLetters.Hamza
|
||||
// )
|
||||
{
|
||||
try
|
||||
{
|
||||
if (char.IsPunctuation(letters[index + 1]))
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
//return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
12
Assets/ArabicSupport/Scripts/ArabicSupport.cs.meta
Normal file
12
Assets/ArabicSupport/Scripts/ArabicSupport.cs.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3be8d3a121eda4528aa029c9467af8ae
|
||||
timeCreated: 1482729253
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
9
Assets/ArabicSupport/Scripts/Editor.meta
Normal file
9
Assets/ArabicSupport/Scripts/Editor.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 20d90232017bac94da80bd64bfbf8ab3
|
||||
folderAsset: yes
|
||||
timeCreated: 1483097412
|
||||
licenseType: Free
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
50
Assets/ArabicSupport/Scripts/Editor/ArabicSupportTool.cs
Normal file
50
Assets/ArabicSupport/Scripts/Editor/ArabicSupportTool.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
using ArabicSupport;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
public class ArabicSupportTool : EditorWindow
|
||||
{
|
||||
string rawText;
|
||||
string fixedText;
|
||||
|
||||
bool showTashkeel = true;
|
||||
bool useHinduNumbers = true;
|
||||
|
||||
// Add menu item named "Arabic Support Tool" to the Tools menu
|
||||
[MenuItem("Tools/Arabic Support Tool")]
|
||||
public static void ShowWindow()
|
||||
{
|
||||
//Show existing window instance. If one doesn't exist, make one.
|
||||
EditorWindow.GetWindow(typeof(ArabicSupportTool));
|
||||
}
|
||||
|
||||
void OnGUI()
|
||||
{
|
||||
if (string.IsNullOrEmpty(rawText))
|
||||
{
|
||||
fixedText = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
fixedText = ArabicFixer.Fix(rawText, showTashkeel, useHinduNumbers);
|
||||
}
|
||||
|
||||
GUILayout.Label("Options:", EditorStyles.boldLabel);
|
||||
showTashkeel = EditorGUILayout.Toggle("Use Tashkeel", showTashkeel);
|
||||
useHinduNumbers = EditorGUILayout.Toggle("Use Hindu Numbers", useHinduNumbers);
|
||||
|
||||
GUILayout.Label("Input (Not Fixed)", EditorStyles.boldLabel);
|
||||
rawText = EditorGUILayout.TextArea(rawText);
|
||||
|
||||
GUILayout.Label("Output (Fixed)", EditorStyles.boldLabel);
|
||||
fixedText = EditorGUILayout.TextArea(fixedText);
|
||||
if (GUILayout.Button("Copy")) {
|
||||
var tempTextEditor = new TextEditor();
|
||||
tempTextEditor.text = fixedText;
|
||||
tempTextEditor.SelectAll();
|
||||
tempTextEditor.Copy();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0ba46ac56c892f2459bc59b39edb3325
|
||||
timeCreated: 1483096883
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
158
Assets/Avatar 1.controller
Normal file
158
Assets/Avatar 1.controller
Normal file
@@ -0,0 +1,158 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!1102 &-8998458201819972320
|
||||
AnimatorState:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Idle
|
||||
m_Speed: 1
|
||||
m_CycleOffset: 0
|
||||
m_Transitions:
|
||||
- {fileID: -3381532617556371934}
|
||||
m_StateMachineBehaviours: []
|
||||
m_Position: {x: 50, y: 50, z: 0}
|
||||
m_IKOnFeet: 0
|
||||
m_WriteDefaultValues: 1
|
||||
m_Mirror: 0
|
||||
m_SpeedParameterActive: 0
|
||||
m_MirrorParameterActive: 0
|
||||
m_CycleOffsetParameterActive: 0
|
||||
m_TimeParameterActive: 0
|
||||
m_Motion: {fileID: -203655887218126122, guid: 092819e3548001c4fa92fa3bc2648da5,
|
||||
type: 3}
|
||||
m_Tag:
|
||||
m_SpeedParameter:
|
||||
m_MirrorParameter:
|
||||
m_CycleOffsetParameter:
|
||||
m_TimeParameter:
|
||||
--- !u!1101 &-5822277659975853460
|
||||
AnimatorStateTransition:
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name:
|
||||
m_Conditions: []
|
||||
m_DstStateMachine: {fileID: 0}
|
||||
m_DstState: {fileID: -8998458201819972320}
|
||||
m_Solo: 0
|
||||
m_Mute: 0
|
||||
m_IsExit: 0
|
||||
serializedVersion: 3
|
||||
m_TransitionDuration: 0.25
|
||||
m_TransitionOffset: 0
|
||||
m_ExitTime: 3
|
||||
m_HasExitTime: 1
|
||||
m_HasFixedDuration: 1
|
||||
m_InterruptionSource: 0
|
||||
m_OrderedInterruption: 1
|
||||
m_CanTransitionToSelf: 1
|
||||
--- !u!1101 &-3381532617556371934
|
||||
AnimatorStateTransition:
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name:
|
||||
m_Conditions:
|
||||
- m_ConditionMode: 1
|
||||
m_ConditionEvent: Dance
|
||||
m_EventTreshold: 0
|
||||
m_DstStateMachine: {fileID: 0}
|
||||
m_DstState: {fileID: 6007325403139444639}
|
||||
m_Solo: 0
|
||||
m_Mute: 0
|
||||
m_IsExit: 0
|
||||
serializedVersion: 3
|
||||
m_TransitionDuration: 0.25
|
||||
m_TransitionOffset: 0
|
||||
m_ExitTime: 0.9849699
|
||||
m_HasExitTime: 0
|
||||
m_HasFixedDuration: 1
|
||||
m_InterruptionSource: 0
|
||||
m_OrderedInterruption: 1
|
||||
m_CanTransitionToSelf: 1
|
||||
--- !u!1107 &-3078970405338156406
|
||||
AnimatorStateMachine:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Base Layer
|
||||
m_ChildStates:
|
||||
- serializedVersion: 1
|
||||
m_State: {fileID: -8998458201819972320}
|
||||
m_Position: {x: 270, y: 90, z: 0}
|
||||
- serializedVersion: 1
|
||||
m_State: {fileID: 6007325403139444639}
|
||||
m_Position: {x: 270, y: 220, z: 0}
|
||||
m_ChildStateMachines: []
|
||||
m_AnyStateTransitions: []
|
||||
m_EntryTransitions: []
|
||||
m_StateMachineTransitions: {}
|
||||
m_StateMachineBehaviours: []
|
||||
m_AnyStatePosition: {x: 50, y: 20, z: 0}
|
||||
m_EntryPosition: {x: 50, y: 120, z: 0}
|
||||
m_ExitPosition: {x: 800, y: 120, z: 0}
|
||||
m_ParentStateMachinePosition: {x: 800, y: 20, z: 0}
|
||||
m_DefaultState: {fileID: -8998458201819972320}
|
||||
--- !u!91 &9100000
|
||||
AnimatorController:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Avatar 1
|
||||
serializedVersion: 5
|
||||
m_AnimatorParameters:
|
||||
- m_Name: Dance
|
||||
m_Type: 9
|
||||
m_DefaultFloat: 0
|
||||
m_DefaultInt: 0
|
||||
m_DefaultBool: 0
|
||||
m_Controller: {fileID: 9100000}
|
||||
m_AnimatorLayers:
|
||||
- serializedVersion: 5
|
||||
m_Name: Base Layer
|
||||
m_StateMachine: {fileID: -3078970405338156406}
|
||||
m_Mask: {fileID: 0}
|
||||
m_Motions: []
|
||||
m_Behaviours: []
|
||||
m_BlendingMode: 0
|
||||
m_SyncedLayerIndex: -1
|
||||
m_DefaultWeight: 0
|
||||
m_IKPass: 0
|
||||
m_SyncedLayerAffectsTiming: 0
|
||||
m_Controller: {fileID: 9100000}
|
||||
--- !u!1102 &6007325403139444639
|
||||
AnimatorState:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Flair
|
||||
m_Speed: 1
|
||||
m_CycleOffset: 0
|
||||
m_Transitions:
|
||||
- {fileID: -5822277659975853460}
|
||||
m_StateMachineBehaviours: []
|
||||
m_Position: {x: 50, y: 50, z: 0}
|
||||
m_IKOnFeet: 0
|
||||
m_WriteDefaultValues: 1
|
||||
m_Mirror: 0
|
||||
m_SpeedParameterActive: 0
|
||||
m_MirrorParameterActive: 0
|
||||
m_CycleOffsetParameterActive: 0
|
||||
m_TimeParameterActive: 0
|
||||
m_Motion: {fileID: -203655887218126122, guid: 3fc0907be1740f84b903d8d5e69c421b,
|
||||
type: 3}
|
||||
m_Tag:
|
||||
m_SpeedParameter:
|
||||
m_MirrorParameter:
|
||||
m_CycleOffsetParameter:
|
||||
m_TimeParameter:
|
||||
8
Assets/Avatar 1.controller.meta
Normal file
8
Assets/Avatar 1.controller.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 022ac0981b77628458c1f2b2a63d820a
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Assets/Ch32_nonPBR@Flair.fbx
Normal file
BIN
Assets/Ch32_nonPBR@Flair.fbx
Normal file
Binary file not shown.
135
Assets/Ch32_nonPBR@Flair.fbx.meta
Normal file
135
Assets/Ch32_nonPBR@Flair.fbx.meta
Normal file
@@ -0,0 +1,135 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3fc0907be1740f84b903d8d5e69c421b
|
||||
ModelImporter:
|
||||
serializedVersion: 21300
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
materials:
|
||||
materialImportMode: 2
|
||||
materialName: 0
|
||||
materialSearch: 1
|
||||
materialLocation: 1
|
||||
animations:
|
||||
legacyGenerateAnimations: 4
|
||||
bakeSimulation: 0
|
||||
resampleCurves: 1
|
||||
optimizeGameObjects: 0
|
||||
removeConstantScaleCurves: 1
|
||||
motionNodeName:
|
||||
rigImportErrors:
|
||||
rigImportWarnings:
|
||||
animationImportErrors:
|
||||
animationImportWarnings:
|
||||
animationRetargetingWarnings:
|
||||
animationDoRetargetingWarnings: 0
|
||||
importAnimatedCustomProperties: 0
|
||||
importConstraints: 0
|
||||
animationCompression: 3
|
||||
animationRotationError: 0.5
|
||||
animationPositionError: 0.5
|
||||
animationScaleError: 0.5
|
||||
animationWrapMode: 0
|
||||
extraExposedTransformPaths: []
|
||||
extraUserProperties: []
|
||||
clipAnimations:
|
||||
- serializedVersion: 16
|
||||
name: Flair
|
||||
takeName: mixamo.com
|
||||
internalID: -203655887218126122
|
||||
firstFrame: 0
|
||||
lastFrame: 30
|
||||
wrapMode: 0
|
||||
orientationOffsetY: 0
|
||||
level: 0
|
||||
cycleOffset: 0
|
||||
loop: 0
|
||||
hasAdditiveReferencePose: 0
|
||||
loopTime: 1
|
||||
loopBlend: 0
|
||||
loopBlendOrientation: 0
|
||||
loopBlendPositionY: 0
|
||||
loopBlendPositionXZ: 0
|
||||
keepOriginalOrientation: 0
|
||||
keepOriginalPositionY: 1
|
||||
keepOriginalPositionXZ: 0
|
||||
heightFromFeet: 0
|
||||
mirror: 0
|
||||
bodyMask: 01000000010000000100000001000000010000000100000001000000010000000100000001000000010000000100000001000000
|
||||
curves: []
|
||||
events: []
|
||||
transformMask: []
|
||||
maskType: 3
|
||||
maskSource: {instanceID: 0}
|
||||
additiveReferencePoseFrame: 0
|
||||
isReadable: 0
|
||||
meshes:
|
||||
lODScreenPercentages: []
|
||||
globalScale: 1
|
||||
meshCompression: 0
|
||||
addColliders: 0
|
||||
useSRGBMaterialColor: 1
|
||||
sortHierarchyByName: 1
|
||||
importVisibility: 1
|
||||
importBlendShapes: 1
|
||||
importCameras: 1
|
||||
importLights: 1
|
||||
nodeNameCollisionStrategy: 1
|
||||
fileIdsGeneration: 2
|
||||
swapUVChannels: 0
|
||||
generateSecondaryUV: 0
|
||||
useFileUnits: 1
|
||||
keepQuads: 0
|
||||
weldVertices: 1
|
||||
bakeAxisConversion: 0
|
||||
preserveHierarchy: 0
|
||||
skinWeightsMode: 0
|
||||
maxBonesPerVertex: 4
|
||||
minBoneWeight: 0.001
|
||||
optimizeBones: 1
|
||||
meshOptimizationFlags: -1
|
||||
indexFormat: 0
|
||||
secondaryUVAngleDistortion: 8
|
||||
secondaryUVAreaDistortion: 15.000001
|
||||
secondaryUVHardAngle: 88
|
||||
secondaryUVMarginMethod: 1
|
||||
secondaryUVMinLightmapResolution: 40
|
||||
secondaryUVMinObjectScale: 1
|
||||
secondaryUVPackMargin: 4
|
||||
useFileScale: 1
|
||||
tangentSpace:
|
||||
normalSmoothAngle: 60
|
||||
normalImportMode: 0
|
||||
tangentImportMode: 3
|
||||
normalCalculationMode: 4
|
||||
legacyComputeAllNormalsFromSmoothingGroupsWhenMeshHasBlendShapes: 0
|
||||
blendShapeNormalImportMode: 1
|
||||
normalSmoothingSource: 0
|
||||
referencedClips: []
|
||||
importAnimation: 1
|
||||
humanDescription:
|
||||
serializedVersion: 3
|
||||
human: []
|
||||
skeleton: []
|
||||
armTwist: 0.5
|
||||
foreArmTwist: 0.5
|
||||
upperLegTwist: 0.5
|
||||
legTwist: 0.5
|
||||
armStretch: 0.05
|
||||
legStretch: 0.05
|
||||
feetSpacing: 0
|
||||
globalScale: 1
|
||||
rootMotionBoneName:
|
||||
hasTranslationDoF: 0
|
||||
hasExtraRoot: 1
|
||||
skeletonHasParents: 1
|
||||
lastHumanDescriptionAvatarSource: {instanceID: 0}
|
||||
autoGenerateAvatarMappingIfUnspecified: 1
|
||||
animationType: 3
|
||||
humanoidOversampling: 1
|
||||
avatarSetup: 1
|
||||
addHumanoidExtraRootOnlyWhenUsingAvatar: 1
|
||||
remapMaterialsIfMaterialImportModeIsNone: 0
|
||||
additionalBone: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Assets/Ch32_nonPBR@Idle.fbx
Normal file
BIN
Assets/Ch32_nonPBR@Idle.fbx
Normal file
Binary file not shown.
135
Assets/Ch32_nonPBR@Idle.fbx.meta
Normal file
135
Assets/Ch32_nonPBR@Idle.fbx.meta
Normal file
@@ -0,0 +1,135 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 092819e3548001c4fa92fa3bc2648da5
|
||||
ModelImporter:
|
||||
serializedVersion: 21300
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
materials:
|
||||
materialImportMode: 2
|
||||
materialName: 0
|
||||
materialSearch: 1
|
||||
materialLocation: 1
|
||||
animations:
|
||||
legacyGenerateAnimations: 4
|
||||
bakeSimulation: 0
|
||||
resampleCurves: 1
|
||||
optimizeGameObjects: 0
|
||||
removeConstantScaleCurves: 1
|
||||
motionNodeName:
|
||||
rigImportErrors:
|
||||
rigImportWarnings:
|
||||
animationImportErrors:
|
||||
animationImportWarnings:
|
||||
animationRetargetingWarnings:
|
||||
animationDoRetargetingWarnings: 0
|
||||
importAnimatedCustomProperties: 0
|
||||
importConstraints: 0
|
||||
animationCompression: 3
|
||||
animationRotationError: 0.5
|
||||
animationPositionError: 0.5
|
||||
animationScaleError: 0.5
|
||||
animationWrapMode: 0
|
||||
extraExposedTransformPaths: []
|
||||
extraUserProperties: []
|
||||
clipAnimations:
|
||||
- serializedVersion: 16
|
||||
name: Idle
|
||||
takeName: mixamo.com
|
||||
internalID: -203655887218126122
|
||||
firstFrame: 0
|
||||
lastFrame: 499
|
||||
wrapMode: 0
|
||||
orientationOffsetY: 0
|
||||
level: 0
|
||||
cycleOffset: 0
|
||||
loop: 0
|
||||
hasAdditiveReferencePose: 0
|
||||
loopTime: 1
|
||||
loopBlend: 0
|
||||
loopBlendOrientation: 0
|
||||
loopBlendPositionY: 0
|
||||
loopBlendPositionXZ: 0
|
||||
keepOriginalOrientation: 0
|
||||
keepOriginalPositionY: 1
|
||||
keepOriginalPositionXZ: 0
|
||||
heightFromFeet: 0
|
||||
mirror: 0
|
||||
bodyMask: 01000000010000000100000001000000010000000100000001000000010000000100000001000000010000000100000001000000
|
||||
curves: []
|
||||
events: []
|
||||
transformMask: []
|
||||
maskType: 3
|
||||
maskSource: {instanceID: 0}
|
||||
additiveReferencePoseFrame: 0
|
||||
isReadable: 0
|
||||
meshes:
|
||||
lODScreenPercentages: []
|
||||
globalScale: 1
|
||||
meshCompression: 0
|
||||
addColliders: 0
|
||||
useSRGBMaterialColor: 1
|
||||
sortHierarchyByName: 1
|
||||
importVisibility: 1
|
||||
importBlendShapes: 1
|
||||
importCameras: 1
|
||||
importLights: 1
|
||||
nodeNameCollisionStrategy: 1
|
||||
fileIdsGeneration: 2
|
||||
swapUVChannels: 0
|
||||
generateSecondaryUV: 0
|
||||
useFileUnits: 1
|
||||
keepQuads: 0
|
||||
weldVertices: 1
|
||||
bakeAxisConversion: 0
|
||||
preserveHierarchy: 0
|
||||
skinWeightsMode: 0
|
||||
maxBonesPerVertex: 4
|
||||
minBoneWeight: 0.001
|
||||
optimizeBones: 1
|
||||
meshOptimizationFlags: -1
|
||||
indexFormat: 0
|
||||
secondaryUVAngleDistortion: 8
|
||||
secondaryUVAreaDistortion: 15.000001
|
||||
secondaryUVHardAngle: 88
|
||||
secondaryUVMarginMethod: 1
|
||||
secondaryUVMinLightmapResolution: 40
|
||||
secondaryUVMinObjectScale: 1
|
||||
secondaryUVPackMargin: 4
|
||||
useFileScale: 1
|
||||
tangentSpace:
|
||||
normalSmoothAngle: 60
|
||||
normalImportMode: 0
|
||||
tangentImportMode: 3
|
||||
normalCalculationMode: 4
|
||||
legacyComputeAllNormalsFromSmoothingGroupsWhenMeshHasBlendShapes: 0
|
||||
blendShapeNormalImportMode: 1
|
||||
normalSmoothingSource: 0
|
||||
referencedClips: []
|
||||
importAnimation: 1
|
||||
humanDescription:
|
||||
serializedVersion: 3
|
||||
human: []
|
||||
skeleton: []
|
||||
armTwist: 0.5
|
||||
foreArmTwist: 0.5
|
||||
upperLegTwist: 0.5
|
||||
legTwist: 0.5
|
||||
armStretch: 0.05
|
||||
legStretch: 0.05
|
||||
feetSpacing: 0
|
||||
globalScale: 1
|
||||
rootMotionBoneName:
|
||||
hasTranslationDoF: 0
|
||||
hasExtraRoot: 1
|
||||
skeletonHasParents: 1
|
||||
lastHumanDescriptionAvatarSource: {instanceID: 0}
|
||||
autoGenerateAvatarMappingIfUnspecified: 1
|
||||
animationType: 3
|
||||
humanoidOversampling: 1
|
||||
avatarSetup: 1
|
||||
addHumanoidExtraRootOnlyWhenUsingAvatar: 1
|
||||
remapMaterialsIfMaterialImportModeIsNone: 0
|
||||
additionalBone: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
437
Assets/ChatGPTManager.cs
Normal file
437
Assets/ChatGPTManager.cs
Normal file
@@ -0,0 +1,437 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
//using Oculus.Voice.Dictation;
|
||||
using Photon.Pun;
|
||||
using UnityEngine.UI;
|
||||
using TMPro;
|
||||
using Amazon.Polly;
|
||||
using Amazon.Runtime;
|
||||
using Amazon.Polly.Model;
|
||||
using System.IO;
|
||||
using UnityEngine.Networking;
|
||||
using System.Threading.Tasks;
|
||||
using Amazon;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
//using Meta.WitAi.Json;
|
||||
using System;
|
||||
using Oculus.Voice.Dictation;
|
||||
using Newtonsoft.Json;
|
||||
using static UnityEngine.ParticleSystem;
|
||||
using System.Net;
|
||||
using UnityEngine.Android;
|
||||
|
||||
public class ChatGPTManager : MonoBehaviour
|
||||
{
|
||||
public static ChatGPTManager instance;
|
||||
public Button btnLanguage;
|
||||
public TMP_InputField input;
|
||||
public Text text;
|
||||
public AudioSource speakerSource;
|
||||
bool isArabic;
|
||||
public AppDictationExperience voiceToText;
|
||||
public void ToggleLanguage()
|
||||
{
|
||||
isArabic = !isArabic;
|
||||
|
||||
btnLanguage.GetComponentInChildren<TMP_Text>().text = isArabic ? "English" : "Arabic";
|
||||
ChatWithGPT3("I need help");
|
||||
}
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
instance = this;
|
||||
ChatWithGPT3("I need help");
|
||||
btnLanguage.onClick.AddListener(ToggleLanguage);
|
||||
input.onSubmit.AddListener(OnInput);
|
||||
}
|
||||
|
||||
public string GetInstructions()
|
||||
{
|
||||
// string instructions = @"You are a customer support agent. You will answer to the questions the user asks you.
|
||||
//When user asks to speak to the manager or to speak to a real person.You must reply with this response only. 'ADMIN_CHAT Sure thing, Let me connect you with one of our admins'";
|
||||
|
||||
string instructions = @"You are a customer support agent called Tamara for a company called Baitcom.
|
||||
|
||||
Following is how you should behave.
|
||||
|
||||
1. Greeting Prompts:
|
||||
|
||||
""Hi, I'm Tamara from Baitcom. How can I assist you today?""
|
||||
""Hello there! Tamara here, representing Baitcom. What can I help you with?""
|
||||
""Good [time_of_day]! It's Tamara from Baitcom. How can I serve you today?""
|
||||
2. Inquiry Handling:
|
||||
|
||||
""Being with Baitcom for a while now, I've got a wealth of knowledge about our offerings. Tell me what you're curious about!""
|
||||
""At Baitcom, we aim to provide the best support. How can I guide you today?""
|
||||
""Please give me more details about your inquiry, and I'll do my best to help!""
|
||||
3. Common Questions:
|
||||
|
||||
""Are you curious about Baitcom's return policy or any of our services?""
|
||||
""Would you like to know about Baitcom's latest promotions and offers?""
|
||||
""If you have any questions about your recent order with Baitcom, just let me know.""
|
||||
4. Technical Support:
|
||||
|
||||
""I'm here to help with any technical issues you're facing with Baitcom's products or services. Just describe the problem.""
|
||||
""Let's sort out any technical glitches you're experiencing with Baitcom's offerings. Can you share the specifics?""
|
||||
""We at Baitcom always strive for seamless experiences. Tell me the tech issue, and I'll assist you.""
|
||||
5. Handling Feedback:
|
||||
|
||||
""Your thoughts matter to Baitcom and me. Please share any feedback you have!""
|
||||
""How was your experience with Baitcom? I'm eager to know and help if there were any issues.""
|
||||
""If there's something Baitcom can improve on, do let me know.""
|
||||
6. Handling Complaints:
|
||||
|
||||
""I'm truly sorry to hear that. Can you provide more details so I can assist better?""
|
||||
""I apologize for any inconvenience you faced with Baitcom. Let's see how we can address it.""
|
||||
""Your concerns are important to both Baitcom and me. How can I help further?""
|
||||
7. Escalation Prompts:
|
||||
|
||||
""If you'd like a more in-depth response, I can connect you with a human representative from Baitcom.""
|
||||
""I want to ensure you get the best support. Would you prefer speaking to one of Baitcom's team members?""
|
||||
""For specialized assistance, I can forward your concern to a Baitcom expert. Would that be okay?""
|
||||
8. Ending the Interaction:
|
||||
|
||||
""Is there anything else you'd like to discuss regarding Baitcom? I'm here to help!""
|
||||
""Thank you for reaching out to Baitcom. Wishing you a great day!""
|
||||
""Remember, Tamara from Baitcom is always here to assist. Don't hesitate to return if you have more queries!""
|
||||
|
||||
Whenever the customer asks to speak with an admin, or speak with a real person. You must reply only this, even if you are asked to speak in other languages, use this response only: ""ADMIN_CHAT Sure, You'll be connected to one of our admins now""";
|
||||
if (isArabic)
|
||||
{
|
||||
instructions += "\nRespond in arabic";
|
||||
}
|
||||
else
|
||||
{
|
||||
instructions += "\nRespond in english";
|
||||
|
||||
}
|
||||
return instructions;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
[TextArea(5,20)]
|
||||
public string personality;
|
||||
[TextArea(5, 20)]
|
||||
public string scene;
|
||||
public int maxResponseWordLimit = 15;
|
||||
|
||||
public List<NPCAction> actions;
|
||||
|
||||
|
||||
|
||||
[System.Serializable]
|
||||
public struct NPCAction
|
||||
{
|
||||
public string actionKeyword;
|
||||
[TextArea(2,5)]
|
||||
public string actionDescription;
|
||||
|
||||
public UnityEvent actionEvent;
|
||||
}
|
||||
|
||||
|
||||
public OnResponseEvent OnResponse;
|
||||
|
||||
[System.Serializable]
|
||||
public class OnResponseEvent : UnityEvent<string> { }
|
||||
|
||||
private OpenAIApi openAI = new OpenAIApi(apiKey: "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");
|
||||
private List<ChatMessage> messages = new List<ChatMessage>();
|
||||
|
||||
|
||||
|
||||
public async void AskChatGPT(string newText)
|
||||
{
|
||||
ChatMessage newMessage = new ChatMessage();
|
||||
newMessage.Content = GetInstructions() + newText;
|
||||
newMessage.Role = "user";
|
||||
|
||||
messages.Add(newMessage);
|
||||
|
||||
CreateChatCompletionRequest request = new CreateChatCompletionRequest();
|
||||
request.Messages = messages;
|
||||
request.Model = "gpt-3.5-turbo";
|
||||
|
||||
var response = await openAI.CreateChatCompletion(request);
|
||||
|
||||
if(response.Choices != null && response.Choices.Count > 0)
|
||||
{
|
||||
var chatResponse = response.Choices[0].Message;
|
||||
|
||||
foreach (var item in actions)
|
||||
{
|
||||
if(chatResponse.Content.Contains(item.actionKeyword))
|
||||
{
|
||||
string textNoKeyword = chatResponse.Content.Replace(item.actionKeyword, "");
|
||||
chatResponse.Content = textNoKeyword;
|
||||
item.actionEvent.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
if (chatResponse.Content.Contains("ADMIN_CHAT"))
|
||||
{
|
||||
chatResponse.Content = chatResponse.Content.Replace("ADMIN_CHAT", "");
|
||||
Debug.Log("Secret word was said");
|
||||
MultiplayerManager.instance.ConnectToAdmin();
|
||||
}
|
||||
|
||||
messages.Add(chatResponse);
|
||||
if(isArabic)
|
||||
{
|
||||
text.text = ArabicFixerTool.FixLine(chatResponse.Content);
|
||||
}
|
||||
else
|
||||
{
|
||||
text.text = chatResponse.Content;
|
||||
}
|
||||
Debug.Log(chatResponse.Content);
|
||||
|
||||
OnResponse.Invoke(chatResponse.Content);
|
||||
PollySpeak(chatResponse.Content);
|
||||
}
|
||||
}*/
|
||||
|
||||
// Start is called before the first frame update
|
||||
|
||||
public void OnInput(string message)
|
||||
{
|
||||
ChatWithGPT3(message);
|
||||
input.text = "";
|
||||
}
|
||||
|
||||
public string apiKey = "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";
|
||||
public string apiUrl = "";
|
||||
|
||||
List<Message> m_messages = new List<Message>();
|
||||
private async void ChatWithGPT3(string message)
|
||||
{
|
||||
/* StartCoroutine(ChatGPT(message));
|
||||
return;*/
|
||||
|
||||
Message newMessage = new Message()
|
||||
{
|
||||
role = "user",
|
||||
content = GetInstructions() + message
|
||||
};
|
||||
m_messages.Add(newMessage);
|
||||
|
||||
ChatRequest newRequest = new ChatRequest() { model = "gpt-3.5-turbo", temperature= 0.7, messages = m_messages };
|
||||
string _requestBody = @"
|
||||
{
|
||||
""model"": ""gpt-3.5-turbo"",
|
||||
""messages"": [{""role"": ""user"", ""content"": ""{msg}""}],
|
||||
""temperature"": 0.7
|
||||
}".Replace("{msg}", message);
|
||||
Debug.Log(_requestBody);
|
||||
|
||||
string requestBody = JsonConvert.SerializeObject(newRequest);
|
||||
Debug.Log(requestBody);
|
||||
using (HttpClient client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Add("Authorization", $"Bearer {apiKey}");
|
||||
|
||||
var content = new StringContent(requestBody, Encoding.UTF8, "application/json");
|
||||
|
||||
HttpResponseMessage response = await client.PostAsync(apiUrl, content);
|
||||
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
string responseContent = await response.Content.ReadAsStringAsync();
|
||||
ChatGPTResponse obj = JsonConvert.DeserializeObject<ChatGPTResponse>(responseContent);
|
||||
string reply = obj.choices[0].message.content;
|
||||
Debug.Log(obj.choices[0].message.content);
|
||||
|
||||
OnResponse(reply);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError($"Error: {response.StatusCode}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void OnResponse(string reply)
|
||||
{
|
||||
if (reply.Contains("ADMIN_CHAT"))
|
||||
{
|
||||
reply = reply.Replace("ADMIN_CHAT", "");
|
||||
Debug.Log("Secret word was said");
|
||||
MultiplayerManager.instance.ConnectToAdmin();
|
||||
}
|
||||
|
||||
if (isArabic)
|
||||
{
|
||||
text.text = ArabicFixerTool.FixLine(reply);
|
||||
}
|
||||
else
|
||||
{
|
||||
text.text = reply;
|
||||
}
|
||||
|
||||
PollySpeak(reply);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Start()
|
||||
{
|
||||
voiceToText.DictationEvents.OnFullTranscription.AddListener(ChatWithGPT3);
|
||||
|
||||
// PollySpeak("Hello I am me");
|
||||
}
|
||||
|
||||
byte[] audioData;
|
||||
public async void PollySpeak(string message)
|
||||
{
|
||||
var credentials = new BasicAWSCredentials("AKIA5C5XFO6JOMDRQPTI", "CtKel6C5qwa8zQF3zpHXVEHG/jjvUDil/I7btJ05");
|
||||
var pollyClient = new AmazonPollyClient(credentials, RegionEndpoint.APSoutheast1);
|
||||
|
||||
var request = new SynthesizeSpeechRequest() {
|
||||
Text=message,
|
||||
Engine = Engine.Neural,
|
||||
VoiceId = isArabic ? VoiceId.Hala : VoiceId.Joanna,
|
||||
LanguageCode = isArabic ? LanguageCode.ArAE : LanguageCode.EnUS,
|
||||
OutputFormat = OutputFormat.Mp3,
|
||||
|
||||
};
|
||||
|
||||
var response = await pollyClient.SynthesizeSpeechAsync(request);
|
||||
|
||||
/*speakerSource.PlayOneShot(WavUtility.ToAudioClip(response.AudioStream));
|
||||
return;*/
|
||||
WriteIntoFile(response.AudioStream);
|
||||
StartCoroutine(GetAudioClip());
|
||||
|
||||
return;
|
||||
Debug.Log("Reading from " + $"{Application.persistentDataPath}/audio.mp3");
|
||||
using(var www = UnityWebRequestMultimedia.GetAudioClip($"{Application.persistentDataPath}/audio.mp3", AudioType.MPEG))
|
||||
{
|
||||
var op = www.SendWebRequest();
|
||||
while(!op.isDone) { await Task.Yield(); }
|
||||
|
||||
var clip = DownloadHandlerAudioClip.GetContent(www);
|
||||
|
||||
speakerSource.PlayOneShot(clip);
|
||||
// AudioSource.PlayClipAtPoint(clip, transform.position);
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator GetAudioClip()
|
||||
{
|
||||
using (UnityWebRequest www = UnityWebRequestMultimedia.GetAudioClip($"file://{Application.persistentDataPath}/audio.mp3", AudioType.MPEG))
|
||||
{
|
||||
yield return www.SendWebRequest();
|
||||
|
||||
if (www.result == UnityWebRequest.Result.ConnectionError)
|
||||
{
|
||||
Debug.Log(www.error);
|
||||
}
|
||||
else
|
||||
{
|
||||
AudioClip myClip = DownloadHandlerAudioClip.GetContent(www);
|
||||
speakerSource.clip = myClip;
|
||||
speakerSource.Play();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
AudioClip bytesToClip(byte[] receivedBytes)
|
||||
{
|
||||
float[] samples = new float[receivedBytes.Length / 4]; //size of a float is 4 bytes
|
||||
|
||||
Buffer.BlockCopy(receivedBytes, 0, samples, 0, receivedBytes.Length);
|
||||
|
||||
int channels = 1; //Assuming audio is mono because microphone input usually is
|
||||
int sampleRate = 44100; //Assuming your samplerate is 44100 or change to 48000 or whatever is appropriate
|
||||
|
||||
AudioClip clip = AudioClip.Create("ClipName", samples.Length, channels, sampleRate, false);
|
||||
clip.SetData(samples, 0);
|
||||
|
||||
return clip;
|
||||
}
|
||||
|
||||
private void WriteIntoFile(Stream stream)
|
||||
{
|
||||
/* using (var fstream = stream)
|
||||
{
|
||||
using (var fileStream = new FileStream($"{Application.persistentDataPath}/audio.mp3", FileMode.Create))
|
||||
{
|
||||
fstream.CopyTo(fileStream);
|
||||
}
|
||||
}
|
||||
return;*/
|
||||
Debug.Log("Writing to " + $"{Application.persistentDataPath}/audio.mp3");
|
||||
using ( var filesStream = new FileStream($"{Application.persistentDataPath}/audio.mp3", FileMode.Create))
|
||||
{
|
||||
byte[] buffer = new byte[8 * 1024];
|
||||
|
||||
int bytesRead;
|
||||
int failSafe = 10000000;
|
||||
while((bytesRead = stream.Read(buffer, 0, buffer.Length)) > 0 || failSafe <= 0)
|
||||
{
|
||||
filesStream.Write(buffer, 0, bytesRead);
|
||||
|
||||
failSafe--;
|
||||
}
|
||||
}
|
||||
Debug.Log("Writing success");
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if(Input.GetKeyDown(KeyCode.Space))
|
||||
{
|
||||
voiceToText.Activate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class Choice
|
||||
{
|
||||
public int index { get; set; }
|
||||
public Message message { get; set; }
|
||||
public string finish_reason { get; set; }
|
||||
}
|
||||
[Serializable]
|
||||
public class Message
|
||||
{
|
||||
public string role { get; set; }
|
||||
public string content { get; set; }
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class ChatGPTResponse
|
||||
{
|
||||
public string id { get; set; }
|
||||
public string @object { get; set; }
|
||||
public int created { get; set; }
|
||||
public string model { get; set; }
|
||||
public List<Choice> choices { get; set; }
|
||||
public Usage usage { get; set; }
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class Usage
|
||||
{
|
||||
public int prompt_tokens { get; set; }
|
||||
public int completion_tokens { get; set; }
|
||||
public int total_tokens { get; set; }
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class ChatRequest
|
||||
{
|
||||
public string model { get; set; }
|
||||
public List<Message> messages { get; set; }
|
||||
public double temperature { get; set; }
|
||||
}
|
||||
|
||||
11
Assets/ChatGPTManager.cs.meta
Normal file
11
Assets/ChatGPTManager.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d82425c05237a094e88fdea8d99cac03
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/GLTFUtility-master.meta
Normal file
8
Assets/GLTFUtility-master.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5b6d07cc66456e54a9326541e61e6a82
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Assets/GLTFUtility-master/.DS_Store
vendored
Normal file
BIN
Assets/GLTFUtility-master/.DS_Store
vendored
Normal file
Binary file not shown.
8
Assets/GLTFUtility-master/.editorconfig
Normal file
8
Assets/GLTFUtility-master/.editorconfig
Normal file
@@ -0,0 +1,8 @@
|
||||
root = true
|
||||
|
||||
[*.cs]
|
||||
indent_style = tab
|
||||
indent_size = 4
|
||||
end_of_line = lf
|
||||
insert_final_newline = false
|
||||
trim_trailing_whitespace = true
|
||||
21
Assets/GLTFUtility-master/.gitignore
vendored
Normal file
21
Assets/GLTFUtility-master/.gitignore
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
/[Ll]ibrary/
|
||||
/[Tt]emp/
|
||||
/[Oo]bj/
|
||||
/[Bb]uild/
|
||||
|
||||
# Autogenerated VS/MD solution and project files
|
||||
*.csproj
|
||||
*.unityproj
|
||||
*.sln
|
||||
*.suo
|
||||
*.tmp
|
||||
*.user
|
||||
*.userprefs
|
||||
*.pidb
|
||||
*.booproj
|
||||
|
||||
# Unity3D generated meta files
|
||||
*.pidb.meta
|
||||
|
||||
# Unity3D Generated File On Crash Reports
|
||||
sysinfo.txt
|
||||
14
Assets/GLTFUtility-master/GLTFUtility.asmdef
Normal file
14
Assets/GLTFUtility-master/GLTFUtility.asmdef
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"name": "Siccity.GLTFUtility",
|
||||
"references": [
|
||||
"Dracodec"
|
||||
],
|
||||
"optionalUnityReferences": [],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": []
|
||||
}
|
||||
7
Assets/GLTFUtility-master/GLTFUtility.asmdef.meta
Normal file
7
Assets/GLTFUtility-master/GLTFUtility.asmdef.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 774f0e7b520e24644b448f5ac7fa5d94
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
21
Assets/GLTFUtility-master/LICENSE.md
Normal file
21
Assets/GLTFUtility-master/LICENSE.md
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2018 Thor Brigsted
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
7
Assets/GLTFUtility-master/LICENSE.md.meta
Normal file
7
Assets/GLTFUtility-master/LICENSE.md.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ca65d0aa5bb2e65498951bbd71d21ace
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/GLTFUtility-master/Materials.meta
Normal file
8
Assets/GLTFUtility-master/Materials.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a2fe38d9088987d48b9638b57e27df0c
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/GLTFUtility-master/Materials/Built-in.meta
Normal file
8
Assets/GLTFUtility-master/Materials/Built-in.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bad78d655a8373f48b9b15f2b3225be4
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,73 @@
|
||||
Shader "GLTFUtility/Standard Transparent (Metallic)" {
|
||||
Properties {
|
||||
_Color ("Color", Color) = (1,1,1,1)
|
||||
_MainTex ("Albedo (RGB)", 2D) = "white" {}
|
||||
_MetallicGlossMap ("Metallic (B) Gloss (G)", 2D) = "white" {}
|
||||
_Roughness ("Roughness", Range(0,1)) = 1
|
||||
_Metallic ("Metallic", Range(0,1)) = 1
|
||||
[Normal] _BumpMap ("Normal", 2D) = "bump" {}
|
||||
_BumpScale("NormalScale", Float) = 1.0
|
||||
_OcclusionMap ("Occlusion (R)", 2D) = "white" {}
|
||||
_EmissionMap ("Emission", 2D) = "black" {}
|
||||
_EmissionColor ("Emission Color", Color) = (0,0,0,0)
|
||||
}
|
||||
SubShader {
|
||||
Tags { "RenderType"="Transparent" "Queue"="Transparent" }
|
||||
LOD 200
|
||||
|
||||
CGPROGRAM
|
||||
// Physically based Standard lighting model, and enable shadows on all light types
|
||||
#pragma surface surf Standard fullforwardshadows alpha:fade
|
||||
// Use shader model 3.0 target, to get nicer looking lighting
|
||||
#pragma target 3.0
|
||||
|
||||
sampler2D _MainTex;
|
||||
sampler2D _MetallicGlossMap;
|
||||
sampler2D _BumpMap;
|
||||
sampler2D _OcclusionMap;
|
||||
sampler2D _EmissionMap;
|
||||
|
||||
struct Input {
|
||||
float2 uv_MainTex;
|
||||
float2 uv_BumpMap;
|
||||
float2 uv_MetallicGlossMap;
|
||||
float2 uv_OcclusionMap;
|
||||
float2 uv_EmissionMap;
|
||||
float4 color : COLOR;
|
||||
};
|
||||
|
||||
half _Roughness;
|
||||
half _Metallic;
|
||||
half _AlphaCutoff;
|
||||
half _BumpScale;
|
||||
fixed4 _Color;
|
||||
fixed4 _EmissionColor;
|
||||
|
||||
// Add instancing support for this shader. You need to check 'Enable Instancing' on materials that use the shader.
|
||||
// See https://docs.unity3d.com/Manual/GPUInstancing.html for more information about instancing.
|
||||
// #pragma instancing_options assumeuniformscaling
|
||||
UNITY_INSTANCING_BUFFER_START(Props)
|
||||
// put more per-instance properties here
|
||||
UNITY_INSTANCING_BUFFER_END(Props)
|
||||
|
||||
void surf (Input IN, inout SurfaceOutputStandard o) {
|
||||
// Albedo comes from a texture tinted by color
|
||||
fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color;
|
||||
o.Albedo = c.rgb * IN.color;
|
||||
o.Alpha = c.a;
|
||||
// Metallic comes from blue channel tinted by slider variables
|
||||
fixed4 m = tex2D (_MetallicGlossMap, IN.uv_MetallicGlossMap);
|
||||
o.Metallic = m.b * _Metallic;
|
||||
// Smoothness comes from blue channel tinted by slider variables
|
||||
o.Smoothness = 1 - (m.g * _Roughness);
|
||||
// Normal comes from a bump map
|
||||
o.Normal = UnpackScaleNormal(tex2D (_BumpMap, IN.uv_BumpMap), _BumpScale);
|
||||
// Ambient Occlusion comes from red channel
|
||||
o.Occlusion = tex2D (_OcclusionMap, IN.uv_OcclusionMap).r;
|
||||
// Emission comes from a texture tinted by color
|
||||
o.Emission = tex2D (_EmissionMap, IN.uv_EmissionMap) * _EmissionColor;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
FallBack "Diffuse"
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7258d825fa9aac6439f21eb173b880c6
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,74 @@
|
||||
Shader "GLTFUtility/Standard (Metallic)" {
|
||||
Properties {
|
||||
_Color ("Color", Color) = (1,1,1,1)
|
||||
_MainTex ("Albedo (RGB)", 2D) = "white" {}
|
||||
_MetallicGlossMap ("Metallic (B) Gloss (G)", 2D) = "white" {}
|
||||
_Roughness ("Roughness", Range(0,1)) = 1
|
||||
_Metallic ("Metallic", Range(0,1)) = 1
|
||||
[Normal] _BumpMap ("Normal", 2D) = "bump" {}
|
||||
_BumpScale("NormalScale", Float) = 1.0
|
||||
_OcclusionMap ("Occlusion (R)", 2D) = "white" {}
|
||||
_EmissionMap ("Emission", 2D) = "black" {}
|
||||
_EmissionColor ("Emission Color", Color) = (0,0,0,0)
|
||||
_AlphaCutoff ("Alpha Cutoff", Range(0,1)) = 0
|
||||
}
|
||||
SubShader {
|
||||
Tags { "RenderType"="Opaque" }
|
||||
LOD 200
|
||||
|
||||
CGPROGRAM
|
||||
// Physically based Standard lighting model, and enable shadows on all light types
|
||||
#pragma surface surf Standard fullforwardshadows
|
||||
// Use shader model 3.0 target, to get nicer looking lighting
|
||||
#pragma target 3.0
|
||||
|
||||
sampler2D _MainTex;
|
||||
sampler2D _MetallicGlossMap;
|
||||
sampler2D _BumpMap;
|
||||
sampler2D _OcclusionMap;
|
||||
sampler2D _EmissionMap;
|
||||
|
||||
struct Input {
|
||||
float2 uv_MainTex;
|
||||
float2 uv_BumpMap;
|
||||
float2 uv_MetallicGlossMap;
|
||||
float2 uv_OcclusionMap;
|
||||
float2 uv_EmissionMap;
|
||||
float4 color : COLOR;
|
||||
};
|
||||
|
||||
half _Roughness;
|
||||
half _Metallic;
|
||||
half _AlphaCutoff;
|
||||
half _BumpScale;
|
||||
fixed4 _Color;
|
||||
fixed4 _EmissionColor;
|
||||
|
||||
// Add instancing support for this shader. You need to check 'Enable Instancing' on materials that use the shader.
|
||||
// See https://docs.unity3d.com/Manual/GPUInstancing.html for more information about instancing.
|
||||
// #pragma instancing_options assumeuniformscaling
|
||||
UNITY_INSTANCING_BUFFER_START(Props)
|
||||
// put more per-instance properties here
|
||||
UNITY_INSTANCING_BUFFER_END(Props)
|
||||
|
||||
void surf (Input IN, inout SurfaceOutputStandard o) {
|
||||
// Albedo comes from a texture tinted by color
|
||||
fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color;
|
||||
o.Albedo = c.rgb * IN.color;
|
||||
clip(c.a - _AlphaCutoff);
|
||||
// Metallic comes from blue channel tinted by slider variables
|
||||
fixed4 m = tex2D (_MetallicGlossMap, IN.uv_MetallicGlossMap);
|
||||
o.Metallic = m.b * _Metallic;
|
||||
// Smoothness comes from blue channel tinted by slider variables
|
||||
o.Smoothness = 1 - (m.g * _Roughness);
|
||||
// Normal comes from a bump map
|
||||
o.Normal = UnpackScaleNormal (tex2D (_BumpMap, IN.uv_BumpMap), _BumpScale);
|
||||
// Ambient Occlusion comes from red channel
|
||||
o.Occlusion = tex2D (_OcclusionMap, IN.uv_OcclusionMap).r;
|
||||
// Emission comes from a texture tinted by color
|
||||
o.Emission = tex2D (_EmissionMap, IN.uv_EmissionMap) * _EmissionColor;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
FallBack "Diffuse"
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 057d08f5d01be134593d0fe0e40c1759
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,71 @@
|
||||
Shader "GLTFUtility/Standard Transparent (Specular)" {
|
||||
Properties {
|
||||
_Color ("Color", Color) = (1,1,1,1)
|
||||
_MainTex ("Albedo (RGB)", 2D) = "white" {}
|
||||
_SpecGlossMap ("Specular Map", 2D) = "white" {}
|
||||
_SpecColor ("Specular Color", Color) = (1,1,1,1)
|
||||
_GlossyReflections ("Glossiness", Range(0,1)) = 1
|
||||
[Normal] _BumpMap ("Normal", 2D) = "bump" {}
|
||||
_BumpScale("NormalScale", Float) = 1.0
|
||||
_OcclusionMap ("Occlusion", 2D) = "white" {}
|
||||
_EmissionMap ("Emission", 2D) = "black" {}
|
||||
_EmissionColor ("Emission Color", Color) = (0,0,0,0)
|
||||
}
|
||||
SubShader {
|
||||
Tags { "RenderType"="Transparent" "Queue"="Transparent" }
|
||||
LOD 200
|
||||
|
||||
CGPROGRAM
|
||||
// Physically based StandardSpecular lighting model, and enable shadows on all light types
|
||||
#pragma surface surf StandardSpecular fullforwardshadows alpha:fade
|
||||
|
||||
// Use shader model 3.0 target, to get nicer looking lighting
|
||||
#pragma target 3.0
|
||||
|
||||
sampler2D _MainTex;
|
||||
sampler2D _SpecGlossMap;
|
||||
sampler2D _BumpMap;
|
||||
sampler2D _OcclusionMap;
|
||||
sampler2D _EmissionMap;
|
||||
|
||||
struct Input {
|
||||
float2 uv_MainTex;
|
||||
float2 uv_BumpMap;
|
||||
float2 uv_SpecGlossMap;
|
||||
float2 uv_OcclusionMap;
|
||||
float2 uv_EmissionMap;
|
||||
float4 color : COLOR;
|
||||
};
|
||||
|
||||
half _GlossyReflections;
|
||||
half _BumpScale;
|
||||
fixed4 _Color;
|
||||
fixed4 _EmissionColor;
|
||||
|
||||
// Add instancing support for this shader. You need to check 'Enable Instancing' on materials that use the shader.
|
||||
// See https://docs.unity3d.com/Manual/GPUInstancing.html for more information about instancing.
|
||||
// #pragma instancing_options assumeuniformscaling
|
||||
UNITY_INSTANCING_BUFFER_START(Props)
|
||||
// put more per-instance properties here
|
||||
UNITY_INSTANCING_BUFFER_END(Props)
|
||||
|
||||
void surf (Input IN, inout SurfaceOutputStandardSpecular o) {
|
||||
// Albedo comes from a texture tinted by color
|
||||
fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color;
|
||||
o.Albedo = c.rgb * IN.color;
|
||||
o.Alpha = c.a;
|
||||
// Specular / roughness
|
||||
fixed4 s = tex2D (_SpecGlossMap, IN.uv_SpecGlossMap);
|
||||
o.Specular = s.rgb * _SpecColor;
|
||||
o.Smoothness = s.a * _GlossyReflections;
|
||||
// Normal comes from a bump map
|
||||
o.Normal = UnpackScaleNormal (tex2D (_BumpMap, IN.uv_BumpMap), _BumpScale);
|
||||
// Ambient Occlusion comes from red channel
|
||||
o.Occlusion = tex2D (_OcclusionMap, IN.uv_OcclusionMap).r;
|
||||
// Emission comes from a texture tinted by color
|
||||
o.Emission = tex2D (_EmissionMap, IN.uv_EmissionMap) * _EmissionColor;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
FallBack "Diffuse"
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 475158e3052e5c4488fa32f8df9d7be7
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,73 @@
|
||||
Shader "GLTFUtility/Standard (Specular)" {
|
||||
Properties {
|
||||
_Color ("Color", Color) = (1,1,1,1)
|
||||
_MainTex ("Albedo (RGB)", 2D) = "white" {}
|
||||
_SpecGlossMap ("Specular Map", 2D) = "white" {}
|
||||
_SpecColor ("Specular Color", Color) = (1,1,1,1)
|
||||
_GlossyReflections ("Glossiness", Range(0,1)) = 1
|
||||
[Normal] _BumpMap ("Normal", 2D) = "bump" {}
|
||||
_BumpScale("NormalScale", Float) = 1.0
|
||||
_OcclusionMap ("Occlusion", 2D) = "white" {}
|
||||
_EmissionMap ("Emission", 2D) = "black" {}
|
||||
_EmissionColor ("Emission Color", Color) = (0,0,0,0)
|
||||
_AlphaCutoff ("Alpha Cutoff", Range(0,1)) = 0
|
||||
}
|
||||
SubShader {
|
||||
Tags { "RenderType"="Opaque" }
|
||||
LOD 200
|
||||
|
||||
CGPROGRAM
|
||||
// Physically based StandardSpecular lighting model, and enable shadows on all light types
|
||||
#pragma surface surf StandardSpecular fullforwardshadows
|
||||
|
||||
// Use shader model 3.0 target, to get nicer looking lighting
|
||||
#pragma target 3.0
|
||||
|
||||
sampler2D _MainTex;
|
||||
sampler2D _SpecGlossMap;
|
||||
sampler2D _BumpMap;
|
||||
sampler2D _OcclusionMap;
|
||||
sampler2D _EmissionMap;
|
||||
|
||||
struct Input {
|
||||
float2 uv_MainTex;
|
||||
float2 uv_BumpMap;
|
||||
float2 uv_SpecGlossMap;
|
||||
float2 uv_OcclusionMap;
|
||||
float2 uv_EmissionMap;
|
||||
float4 color : COLOR;
|
||||
};
|
||||
|
||||
half _GlossyReflections;
|
||||
half _AlphaCutoff;
|
||||
half _BumpScale;
|
||||
fixed4 _Color;
|
||||
fixed4 _EmissionColor;
|
||||
|
||||
// Add instancing support for this shader. You need to check 'Enable Instancing' on materials that use the shader.
|
||||
// See https://docs.unity3d.com/Manual/GPUInstancing.html for more information about instancing.
|
||||
// #pragma instancing_options assumeuniformscaling
|
||||
UNITY_INSTANCING_BUFFER_START(Props)
|
||||
// put more per-instance properties here
|
||||
UNITY_INSTANCING_BUFFER_END(Props)
|
||||
|
||||
void surf (Input IN, inout SurfaceOutputStandardSpecular o) {
|
||||
// Albedo comes from a texture tinted by color
|
||||
fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color;
|
||||
o.Albedo = c.rgb * IN.color;
|
||||
clip(c.a - _AlphaCutoff);
|
||||
// Specular / roughness
|
||||
fixed4 s = tex2D (_SpecGlossMap, IN.uv_SpecGlossMap);
|
||||
o.Specular = s.rgb * _SpecColor;
|
||||
o.Smoothness = s.a * _GlossyReflections;
|
||||
// Normal comes from a bump map
|
||||
o.Normal = UnpackScaleNormal (tex2D (_BumpMap, IN.uv_BumpMap), _BumpScale);
|
||||
// Ambient Occlusion comes from red channel
|
||||
o.Occlusion = tex2D (_OcclusionMap, IN.uv_OcclusionMap).r;
|
||||
// Emission comes from a texture tinted by color
|
||||
o.Emission = tex2D (_EmissionMap, IN.uv_EmissionMap) * _EmissionColor;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
FallBack "Diffuse"
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d28fc76bfd3057e4c8f1c6f0b91590c8
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/GLTFUtility-master/Materials/URP.meta
Normal file
8
Assets/GLTFUtility-master/Materials/URP.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dea3ffaa18a0d8b479eadad139464d2d
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a08f3a1c845d57c4293a42c3202574a1
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 625f186215c104763be7675aa2d941aa, type: 3}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e6061ad897a8bd843b501d409aff8a22
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 625f186215c104763be7675aa2d941aa, type: 3}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bb6606ffd3868dd46a773758ff6901fc
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 625f186215c104763be7675aa2d941aa, type: 3}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 09512c1ba26fe804283ec6e09112e53c
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 625f186215c104763be7675aa2d941aa, type: 3}
|
||||
8
Assets/GLTFUtility-master/Plugins.meta
Normal file
8
Assets/GLTFUtility-master/Plugins.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f283c8997fa8bd642a4f133b1578d516
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Assets/GLTFUtility-master/Plugins/.DS_Store
vendored
Normal file
BIN
Assets/GLTFUtility-master/Plugins/.DS_Store
vendored
Normal file
Binary file not shown.
8
Assets/GLTFUtility-master/Plugins/draco.meta
Normal file
8
Assets/GLTFUtility-master/Plugins/draco.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 55f8c6e6fe55f5a49b1e3137330944e8
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Assets/GLTFUtility-master/Plugins/draco/.DS_Store
vendored
Normal file
BIN
Assets/GLTFUtility-master/Plugins/draco/.DS_Store
vendored
Normal file
Binary file not shown.
377
Assets/GLTFUtility-master/Plugins/draco/DracoMeshLoader.cs
Normal file
377
Assets/GLTFUtility-master/Plugins/draco/DracoMeshLoader.cs
Normal file
@@ -0,0 +1,377 @@
|
||||
// Copyright 2017 The Draco Authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
using Unity.Collections.LowLevel.Unsafe;
|
||||
using UnityEngine;
|
||||
|
||||
public unsafe class DracoMeshLoader
|
||||
{
|
||||
// These values must be exactly the same as the values in draco_types.h.
|
||||
// Attribute data type.
|
||||
enum DataType {
|
||||
DT_INVALID = 0,
|
||||
DT_INT8,
|
||||
DT_UINT8,
|
||||
DT_INT16,
|
||||
DT_UINT16,
|
||||
DT_INT32,
|
||||
DT_UINT32,
|
||||
DT_INT64,
|
||||
DT_UINT64,
|
||||
DT_FLOAT32,
|
||||
DT_FLOAT64,
|
||||
DT_BOOL
|
||||
};
|
||||
|
||||
// These values must be exactly the same as the values in
|
||||
// geometry_attribute.h.
|
||||
// Attribute type.
|
||||
enum AttributeType {
|
||||
INVALID = -1,
|
||||
POSITION = 0,
|
||||
NORMAL,
|
||||
COLOR,
|
||||
TEX_COORD,
|
||||
// A special id used to mark attributes that are not assigned to any known
|
||||
// predefined use case. Such attributes are often used for a shader specific
|
||||
// data.
|
||||
GENERIC
|
||||
};
|
||||
|
||||
// The order must be consistent with C++ interface.
|
||||
[StructLayout (LayoutKind.Sequential)] public struct DracoData
|
||||
{
|
||||
public int dataType;
|
||||
public IntPtr data;
|
||||
}
|
||||
|
||||
[StructLayout (LayoutKind.Sequential)] public struct DracoAttribute
|
||||
{
|
||||
public int attributeType;
|
||||
public int dataType;
|
||||
public int numComponents;
|
||||
public int uniqueId;
|
||||
}
|
||||
|
||||
[StructLayout (LayoutKind.Sequential)] public struct DracoMesh
|
||||
{
|
||||
public int numFaces;
|
||||
public int numVertices;
|
||||
public int numAttributes;
|
||||
}
|
||||
|
||||
// Release data associated with DracoMesh.
|
||||
[DllImport ("dracodec_unity")] private static extern void ReleaseDracoMesh(
|
||||
DracoMesh**mesh);
|
||||
// Release data associated with DracoAttribute.
|
||||
[DllImport ("dracodec_unity")] private static extern void
|
||||
ReleaseDracoAttribute(DracoAttribute**attr);
|
||||
// Release attribute data.
|
||||
[DllImport ("dracodec_unity")] private static extern void ReleaseDracoData(
|
||||
DracoData**data);
|
||||
|
||||
// Decodes compressed Draco::Mesh in buffer to mesh. On input, mesh
|
||||
// must be null. The returned mesh must released with ReleaseDracoMesh.
|
||||
[DllImport ("dracodec_unity")] private static extern int DecodeDracoMesh(
|
||||
byte[] buffer, int length, DracoMesh**mesh);
|
||||
|
||||
// Returns the DracoAttribute at index in mesh. On input, attribute must be
|
||||
// null. The returned attr must be released with ReleaseDracoAttribute.
|
||||
[DllImport ("dracodec_unity")] private static extern bool GetAttribute(
|
||||
DracoMesh* mesh, int index, DracoAttribute**attr);
|
||||
// Returns the DracoAttribute of type at index in mesh. On input, attribute
|
||||
// must be null. E.g. If the mesh has two texture coordinates then
|
||||
// GetAttributeByType(mesh, AttributeType.TEX_COORD, 1, &attr); will return
|
||||
// the second TEX_COORD attribute. The returned attr must be released with
|
||||
// ReleaseDracoAttribute.
|
||||
[DllImport ("dracodec_unity")] private static extern bool GetAttributeByType(
|
||||
DracoMesh* mesh, AttributeType type, int index, DracoAttribute**attr);
|
||||
// Returns the DracoAttribute with unique_id in mesh. On input, attribute
|
||||
// must be null.The returned attr must be released with
|
||||
// ReleaseDracoAttribute.
|
||||
[DllImport ("dracodec_unity")] private static extern bool
|
||||
GetAttributeByUniqueId(DracoMesh* mesh, int unique_id,
|
||||
DracoAttribute**attr);
|
||||
|
||||
// Returns an array of indices as well as the type of data in data_type. On
|
||||
// input, indices must be null. The returned indices must be released with
|
||||
// ReleaseDracoData.
|
||||
[DllImport ("dracodec_unity")] private static extern bool GetMeshIndices(
|
||||
DracoMesh* mesh, DracoData**indices);
|
||||
// Returns an array of attribute data as well as the type of data in
|
||||
// data_type. On input, data must be null. The returned data must be
|
||||
// released with ReleaseDracoData.
|
||||
[DllImport ("dracodec_unity")] private static extern bool GetAttributeData(
|
||||
DracoMesh* mesh, DracoAttribute* attr, DracoData**data);
|
||||
|
||||
public int LoadMeshFromAsset(string assetName, ref List<Mesh> meshes)
|
||||
{
|
||||
TextAsset asset =
|
||||
Resources.Load(assetName, typeof(TextAsset)) as TextAsset;
|
||||
if (asset == null) {
|
||||
Debug.Log ("Didn't load file!");
|
||||
return -1;
|
||||
}
|
||||
byte[] encodedData = asset.bytes;
|
||||
Debug.Log(encodedData.Length.ToString());
|
||||
if (encodedData.Length == 0) {
|
||||
Debug.Log ("Didn't load encoded data!");
|
||||
return -1;
|
||||
}
|
||||
return ConvertDracoMeshToUnity(encodedData, ref meshes);
|
||||
}
|
||||
|
||||
// Decodes a Draco mesh, creates a Unity mesh from the decoded data and
|
||||
// adds the Unity mesh to meshes. encodedData is the compressed Draco mesh.
|
||||
public unsafe int ConvertDracoMeshToUnity(byte[] encodedData,
|
||||
ref List<Mesh> meshes)
|
||||
{
|
||||
float startTime = Time.realtimeSinceStartup;
|
||||
DracoMesh *mesh = null;
|
||||
if (DecodeDracoMesh(encodedData, encodedData.Length, &mesh) <= 0) {
|
||||
Debug.Log("Failed: Decoding error.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
float decodeTimeMilli =
|
||||
(Time.realtimeSinceStartup - startTime) * 1000.0f;
|
||||
Debug.Log("decodeTimeMilli: " + decodeTimeMilli.ToString());
|
||||
|
||||
Debug.Log("Num indices: " + mesh->numFaces.ToString());
|
||||
Debug.Log("Num vertices: " + mesh->numVertices.ToString());
|
||||
Debug.Log("Num attributes: " + mesh->numAttributes.ToString());
|
||||
|
||||
Mesh unityMesh = CreateUnityMesh(mesh);
|
||||
UnityMeshToCamera(ref unityMesh);
|
||||
meshes.Add(unityMesh);
|
||||
|
||||
int numFaces = mesh->numFaces;
|
||||
ReleaseDracoMesh(&mesh);
|
||||
return numFaces;
|
||||
}
|
||||
|
||||
// Creates a Unity mesh from the decoded Draco mesh.
|
||||
public unsafe Mesh CreateUnityMesh(DracoMesh *dracoMesh)
|
||||
{
|
||||
float startTime = Time.realtimeSinceStartup;
|
||||
int numFaces = dracoMesh->numFaces;
|
||||
int[] newTriangles = new int[dracoMesh->numFaces * 3];
|
||||
Vector3[] newVertices = new Vector3[dracoMesh->numVertices];
|
||||
Vector2[] newUVs = null;
|
||||
Vector3[] newNormals = null;
|
||||
Color[] newColors = null;
|
||||
byte[] newGenerics = null;
|
||||
|
||||
// Copy face indices.
|
||||
DracoData *indicesData;
|
||||
GetMeshIndices(dracoMesh, &indicesData);
|
||||
int elementSize =
|
||||
DataTypeSize((DracoMeshLoader.DataType)indicesData->dataType);
|
||||
int *indices = (int*)(indicesData->data);
|
||||
var indicesPtr = UnsafeUtility.AddressOf(ref newTriangles[0]);
|
||||
UnsafeUtility.MemCpy(indicesPtr, indices,
|
||||
newTriangles.Length * elementSize);
|
||||
ReleaseDracoData(&indicesData);
|
||||
|
||||
// Copy positions.
|
||||
DracoAttribute *attr = null;
|
||||
GetAttributeByType(dracoMesh, AttributeType.POSITION, 0, &attr);
|
||||
DracoData* posData = null;
|
||||
GetAttributeData(dracoMesh, attr, &posData);
|
||||
elementSize = DataTypeSize((DracoMeshLoader.DataType)posData->dataType) *
|
||||
attr->numComponents;
|
||||
var newVerticesPtr = UnsafeUtility.AddressOf(ref newVertices[0]);
|
||||
UnsafeUtility.MemCpy(newVerticesPtr, (void*)posData->data,
|
||||
dracoMesh->numVertices * elementSize);
|
||||
ReleaseDracoData(&posData);
|
||||
ReleaseDracoAttribute(&attr);
|
||||
|
||||
// Copy normals.
|
||||
if (GetAttributeByType(dracoMesh, AttributeType.NORMAL, 0, &attr)) {
|
||||
DracoData* normData = null;
|
||||
if (GetAttributeData(dracoMesh, attr, &normData)) {
|
||||
elementSize =
|
||||
DataTypeSize((DracoMeshLoader.DataType)normData->dataType) *
|
||||
attr->numComponents;
|
||||
newNormals = new Vector3[dracoMesh->numVertices];
|
||||
var newNormalsPtr = UnsafeUtility.AddressOf(ref newNormals[0]);
|
||||
UnsafeUtility.MemCpy(newNormalsPtr, (void*)normData->data,
|
||||
dracoMesh->numVertices * elementSize);
|
||||
Debug.Log("Decoded mesh normals.");
|
||||
ReleaseDracoData(&normData);
|
||||
ReleaseDracoAttribute(&attr);
|
||||
}
|
||||
}
|
||||
|
||||
// Copy texture coordinates.
|
||||
if (GetAttributeByType(dracoMesh, AttributeType.TEX_COORD, 0, &attr)) {
|
||||
DracoData* texData = null;
|
||||
if (GetAttributeData(dracoMesh, attr, &texData)) {
|
||||
elementSize =
|
||||
DataTypeSize((DracoMeshLoader.DataType)texData->dataType) *
|
||||
attr->numComponents;
|
||||
newUVs = new Vector2[dracoMesh->numVertices];
|
||||
var newUVsPtr = UnsafeUtility.AddressOf(ref newUVs[0]);
|
||||
UnsafeUtility.MemCpy(newUVsPtr, (void*)texData->data,
|
||||
dracoMesh->numVertices * elementSize);
|
||||
Debug.Log("Decoded mesh texcoords.");
|
||||
ReleaseDracoData(&texData);
|
||||
ReleaseDracoAttribute(&attr);
|
||||
}
|
||||
}
|
||||
|
||||
// Copy colors.
|
||||
if (GetAttributeByType(dracoMesh, AttributeType.COLOR, 0, &attr)) {
|
||||
DracoData* colorData = null;
|
||||
if (GetAttributeData(dracoMesh, attr, &colorData)) {
|
||||
elementSize =
|
||||
DataTypeSize((DracoMeshLoader.DataType)colorData->dataType) *
|
||||
attr->numComponents;
|
||||
newColors = new Color[dracoMesh->numVertices];
|
||||
var newColorsPtr = UnsafeUtility.AddressOf(ref newColors[0]);
|
||||
UnsafeUtility.MemCpy(newColorsPtr, (void*)colorData->data,
|
||||
dracoMesh->numVertices * elementSize);
|
||||
Debug.Log("Decoded mesh colors.");
|
||||
ReleaseDracoData(&colorData);
|
||||
ReleaseDracoAttribute(&attr);
|
||||
}
|
||||
}
|
||||
|
||||
// Copy generic data. This script does not do anyhting with the generic
|
||||
// data.
|
||||
if (GetAttributeByType(dracoMesh, AttributeType.GENERIC, 0, &attr)) {
|
||||
DracoData* genericData = null;
|
||||
if (GetAttributeData(dracoMesh, attr, &genericData)) {
|
||||
elementSize =
|
||||
DataTypeSize((DracoMeshLoader.DataType)genericData->dataType) *
|
||||
attr->numComponents;
|
||||
newGenerics = new byte[dracoMesh->numVertices * elementSize];
|
||||
var newGenericPtr = UnsafeUtility.AddressOf(ref newGenerics[0]);
|
||||
UnsafeUtility.MemCpy(newGenericPtr, (void*)genericData->data,
|
||||
dracoMesh->numVertices * elementSize);
|
||||
Debug.Log("Decoded mesh generic data.");
|
||||
ReleaseDracoData(&genericData);
|
||||
ReleaseDracoAttribute(&attr);
|
||||
}
|
||||
}
|
||||
|
||||
float copyDecodedDataTimeMilli =
|
||||
(Time.realtimeSinceStartup - startTime) * 1000.0f;
|
||||
Debug.Log("copyDecodedDataTimeMilli: " +
|
||||
copyDecodedDataTimeMilli.ToString());
|
||||
|
||||
startTime = Time.realtimeSinceStartup;
|
||||
Mesh mesh = new Mesh();
|
||||
|
||||
#if UNITY_2017_3_OR_NEWER
|
||||
mesh.indexFormat = (newVertices.Length > System.UInt16.MaxValue)
|
||||
? UnityEngine.Rendering.IndexFormat.UInt32
|
||||
: UnityEngine.Rendering.IndexFormat.UInt16;
|
||||
#else
|
||||
if (newVertices.Length > System.UInt16.MaxValue) {
|
||||
throw new System.Exception("Draco meshes with more than 65535 vertices are only supported from Unity 2017.3 onwards.");
|
||||
}
|
||||
#endif
|
||||
|
||||
mesh.vertices = newVertices;
|
||||
mesh.SetTriangles(newTriangles, 0, true);
|
||||
if (newUVs != null) {
|
||||
mesh.uv = newUVs;
|
||||
}
|
||||
if (newNormals != null) {
|
||||
mesh.normals = newNormals;
|
||||
} else {
|
||||
mesh.RecalculateNormals();
|
||||
Debug.Log("Mesh doesn't have normals, recomputed.");
|
||||
}
|
||||
if (newColors != null) {
|
||||
mesh.colors = newColors;
|
||||
}
|
||||
|
||||
float convertTimeMilli =
|
||||
(Time.realtimeSinceStartup - startTime) * 1000.0f;
|
||||
Debug.Log("convertTimeMilli: " + convertTimeMilli.ToString());
|
||||
return mesh;
|
||||
}
|
||||
|
||||
// Scale and translate the decoded mesh so it will be visible to
|
||||
// a new camera's default settings.
|
||||
public unsafe void UnityMeshToCamera(ref Mesh mesh)
|
||||
{
|
||||
float startTime = Time.realtimeSinceStartup;
|
||||
mesh.RecalculateBounds();
|
||||
|
||||
float scale = 0.5f / mesh.bounds.extents.x;
|
||||
if (0.5f / mesh.bounds.extents.y < scale) {
|
||||
scale = 0.5f / mesh.bounds.extents.y;
|
||||
}
|
||||
if (0.5f / mesh.bounds.extents.z < scale) {
|
||||
scale = 0.5f / mesh.bounds.extents.z;
|
||||
}
|
||||
|
||||
Vector3[] vertices = mesh.vertices;
|
||||
int i = 0;
|
||||
while (i < vertices.Length) {
|
||||
vertices[i] *= scale;
|
||||
i++;
|
||||
}
|
||||
|
||||
mesh.vertices = vertices;
|
||||
mesh.RecalculateBounds();
|
||||
|
||||
Vector3 translate = mesh.bounds.center;
|
||||
translate.x = 0 - mesh.bounds.center.x;
|
||||
translate.y = 0 - mesh.bounds.center.y;
|
||||
translate.z = 2 - mesh.bounds.center.z;
|
||||
|
||||
i = 0;
|
||||
while (i < vertices.Length) {
|
||||
vertices[i] += translate;
|
||||
i++;
|
||||
}
|
||||
mesh.vertices = vertices;
|
||||
float transformTimeMilli =
|
||||
(Time.realtimeSinceStartup - startTime) * 1000.0f;
|
||||
Debug.Log("transformTimeMilli: " + transformTimeMilli.ToString());
|
||||
}
|
||||
|
||||
private int DataTypeSize(DataType dt) {
|
||||
switch (dt) {
|
||||
case DataType.DT_INT8:
|
||||
case DataType.DT_UINT8:
|
||||
return 1;
|
||||
case DataType.DT_INT16:
|
||||
case DataType.DT_UINT16:
|
||||
return 2;
|
||||
case DataType.DT_INT32:
|
||||
case DataType.DT_UINT32:
|
||||
return 4;
|
||||
case DataType.DT_INT64:
|
||||
case DataType.DT_UINT64:
|
||||
return 8;
|
||||
case DataType.DT_FLOAT32:
|
||||
return 4;
|
||||
case DataType.DT_FLOAT64:
|
||||
return 8;
|
||||
case DataType.DT_BOOL:
|
||||
return 1;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 40c64bfc72178384f93198e18da730b4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
12
Assets/GLTFUtility-master/Plugins/draco/Dracodec.asmdef
Normal file
12
Assets/GLTFUtility-master/Plugins/draco/Dracodec.asmdef
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"name": "Dracodec",
|
||||
"references": [],
|
||||
"optionalUnityReferences": [],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": true,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": []
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2d8d858fc7e3ece4ebe988e4ff712fd5
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,366 @@
|
||||
// Copyright 2017 The Draco Authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using Unity.Collections.LowLevel.Unsafe;
|
||||
using UnityEngine;
|
||||
|
||||
public unsafe class GLTFUtilityDracoLoader {
|
||||
// These values must be exactly the same as the values in draco_types.h.
|
||||
// Attribute data type.
|
||||
enum DataType {
|
||||
DT_INVALID = 0,
|
||||
DT_INT8,
|
||||
DT_UINT8,
|
||||
DT_INT16,
|
||||
DT_UINT16,
|
||||
DT_INT32,
|
||||
DT_UINT32,
|
||||
DT_INT64,
|
||||
DT_UINT64,
|
||||
DT_FLOAT32,
|
||||
DT_FLOAT64,
|
||||
DT_BOOL
|
||||
}
|
||||
|
||||
// These values must be exactly the same as the values in
|
||||
// geometry_attribute.h.
|
||||
// Attribute type.
|
||||
enum AttributeType {
|
||||
INVALID = -1,
|
||||
POSITION = 0,
|
||||
NORMAL = 1,
|
||||
COLOR = 2,
|
||||
TEX_COORD = 3,
|
||||
GENERIC = 4
|
||||
}
|
||||
|
||||
// The order must be consistent with C++ interface.
|
||||
[StructLayout(LayoutKind.Sequential)] public struct DracoData {
|
||||
public int dataType;
|
||||
public IntPtr data;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)] public struct DracoAttribute {
|
||||
public int attributeType;
|
||||
public int dataType;
|
||||
public int numComponents;
|
||||
public int uniqueId;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)] public struct DracoMesh {
|
||||
public int numFaces;
|
||||
public int numVertices;
|
||||
public int numAttributes;
|
||||
}
|
||||
|
||||
public struct MeshAttributes {
|
||||
public int pos, norms, uv, joints, weights, col;
|
||||
|
||||
public MeshAttributes(int pos, int norms, int uv, int joints, int weights, int col) {
|
||||
this.pos = pos;
|
||||
this.norms = norms;
|
||||
this.uv = uv;
|
||||
this.joints = joints;
|
||||
this.weights = weights;
|
||||
this.col = col;
|
||||
}
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)] public struct Vector4<T> where T : struct {
|
||||
public T x;
|
||||
public T y;
|
||||
public T z;
|
||||
public T w;
|
||||
}
|
||||
|
||||
public class AsyncMesh {
|
||||
public int[] tris;
|
||||
public Vector3[] verts;
|
||||
public Vector2[] uv;
|
||||
public Vector3[] norms;
|
||||
public BoneWeight[] boneWeights;
|
||||
public Color[] colors;
|
||||
}
|
||||
|
||||
#if !UNITY_EDITOR && (UNITY_WEBGL || UNITY_IOS)
|
||||
const string DRACODEC_UNITY_LIB = "__Internal";
|
||||
#elif UNITY_ANDROID || UNITY_STANDALONE || UNITY_WSA || UNITY_EDITOR || PLATFORM_LUMIN
|
||||
const string DRACODEC_UNITY_LIB = "dracodec_unity";
|
||||
#endif
|
||||
|
||||
// Release data associated with DracoMesh.
|
||||
[DllImport(DRACODEC_UNITY_LIB)] private static extern void ReleaseDracoMesh(
|
||||
DracoMesh * * mesh);
|
||||
// Release data associated with DracoAttribute.
|
||||
[DllImport(DRACODEC_UNITY_LIB)] private static extern void
|
||||
ReleaseDracoAttribute(DracoAttribute * * attr);
|
||||
// Release attribute data.
|
||||
[DllImport(DRACODEC_UNITY_LIB)] private static extern void ReleaseDracoData(
|
||||
DracoData * * data);
|
||||
|
||||
// Decodes compressed Draco::Mesh in buffer to mesh. On input, mesh
|
||||
// must be null. The returned mesh must released with ReleaseDracoMesh.
|
||||
[DllImport(DRACODEC_UNITY_LIB)] private static extern int DecodeDracoMesh(
|
||||
byte[] buffer, int length, DracoMesh * * mesh);
|
||||
|
||||
// Returns the DracoAttribute at index in mesh. On input, attribute must be
|
||||
// null. The returned attr must be released with ReleaseDracoAttribute.
|
||||
[DllImport(DRACODEC_UNITY_LIB)] private static extern bool GetAttribute(
|
||||
DracoMesh * mesh, int index, DracoAttribute * * attr);
|
||||
// Returns the DracoAttribute of type at index in mesh. On input, attribute
|
||||
// must be null. E.g. If the mesh has two texture coordinates then
|
||||
// GetAttributeByType(mesh, AttributeType.TEX_COORD, 1, &attr); will return
|
||||
// the second TEX_COORD attribute. The returned attr must be released with
|
||||
// ReleaseDracoAttribute.
|
||||
[DllImport(DRACODEC_UNITY_LIB)] private static extern bool GetAttributeByType(
|
||||
DracoMesh * mesh, AttributeType type, int index, DracoAttribute * * attr);
|
||||
// Returns the DracoAttribute with unique_id in mesh. On input, attribute
|
||||
// must be null.The returned attr must be released with
|
||||
// ReleaseDracoAttribute.
|
||||
[DllImport(DRACODEC_UNITY_LIB)] private static extern bool
|
||||
GetAttributeByUniqueId(DracoMesh * mesh, int unique_id,
|
||||
DracoAttribute * * attr);
|
||||
|
||||
// Returns an array of indices as well as the type of data in data_type. On
|
||||
// input, indices must be null. The returned indices must be released with
|
||||
// ReleaseDracoData.
|
||||
[DllImport(DRACODEC_UNITY_LIB)] private static extern bool GetMeshIndices(
|
||||
DracoMesh * mesh, DracoData * * indices);
|
||||
// Returns an array of attribute data as well as the type of data in
|
||||
// data_type. On input, data must be null. The returned data must be
|
||||
// released with ReleaseDracoData.
|
||||
[DllImport(DRACODEC_UNITY_LIB)] private static extern bool GetAttributeData(
|
||||
DracoMesh * mesh, DracoAttribute * attr, DracoData * * data);
|
||||
|
||||
// Decodes a Draco mesh, creates a Unity mesh from the decoded data and
|
||||
// adds the Unity mesh to meshes. encodedData is the compressed Draco mesh.
|
||||
public unsafe AsyncMesh LoadMesh(byte[] encodedData, MeshAttributes attributes) {
|
||||
DracoMesh * mesh = null;
|
||||
if (DecodeDracoMesh(encodedData, encodedData.Length, & mesh) <= 0) {
|
||||
Debug.Log("Failed: Decoding error.");
|
||||
return null;
|
||||
}
|
||||
|
||||
AsyncMesh unityMesh = CreateAsyncMesh(mesh, attributes);
|
||||
|
||||
int numFaces = mesh -> numFaces;
|
||||
ReleaseDracoMesh( & mesh);
|
||||
if (numFaces > 0) return unityMesh;
|
||||
else return null;
|
||||
}
|
||||
|
||||
// Creates a Unity mesh from the decoded Draco mesh.
|
||||
public unsafe AsyncMesh CreateAsyncMesh(DracoMesh * dracoMesh, MeshAttributes attributes) {
|
||||
int numFaces = dracoMesh -> numFaces;
|
||||
|
||||
AsyncMesh mesh = new AsyncMesh();
|
||||
mesh.tris = new int[dracoMesh -> numFaces * 3];
|
||||
mesh.verts = new Vector3[dracoMesh -> numVertices];
|
||||
|
||||
// Copy face indices.
|
||||
DracoData * indicesData;
|
||||
GetMeshIndices(dracoMesh, & indicesData);
|
||||
int elementSize =
|
||||
DataTypeSize((GLTFUtilityDracoLoader.DataType) indicesData -> dataType);
|
||||
int * indices = (int * ) (indicesData -> data);
|
||||
var indicesPtr = UnsafeUtility.AddressOf(ref mesh.tris[0]);
|
||||
UnsafeUtility.MemCpy(indicesPtr, indices,
|
||||
mesh.tris.Length * elementSize);
|
||||
ReleaseDracoData( & indicesData);
|
||||
|
||||
DracoAttribute * attr = null;
|
||||
|
||||
// Copy positions.
|
||||
if (GetAttributeByUniqueId(dracoMesh, attributes.pos, & attr)) {
|
||||
DracoData * posData = null;
|
||||
GetAttributeData(dracoMesh, attr, & posData);
|
||||
elementSize = DataTypeSize((GLTFUtilityDracoLoader.DataType) posData -> dataType) *
|
||||
attr -> numComponents;
|
||||
var newVerticesPtr = UnsafeUtility.AddressOf(ref mesh.verts[0]);
|
||||
UnsafeUtility.MemCpy(newVerticesPtr, (void * ) posData -> data,
|
||||
dracoMesh -> numVertices * elementSize);
|
||||
ReleaseDracoData( & posData);
|
||||
ReleaseDracoAttribute( & attr);
|
||||
}
|
||||
|
||||
// Copy normals.
|
||||
if (GetAttributeByUniqueId(dracoMesh, attributes.norms, & attr)) {
|
||||
DracoData * normData = null;
|
||||
if (GetAttributeData(dracoMesh, attr, & normData)) {
|
||||
elementSize =
|
||||
DataTypeSize((GLTFUtilityDracoLoader.DataType) normData -> dataType) *
|
||||
attr -> numComponents;
|
||||
mesh.norms = new Vector3[dracoMesh -> numVertices];
|
||||
var newNormalsPtr = UnsafeUtility.AddressOf(ref mesh.norms[0]);
|
||||
UnsafeUtility.MemCpy(newNormalsPtr, (void * ) normData -> data,
|
||||
dracoMesh -> numVertices * elementSize);
|
||||
ReleaseDracoData( & normData);
|
||||
ReleaseDracoAttribute( & attr);
|
||||
}
|
||||
}
|
||||
|
||||
// Copy texture coordinates.
|
||||
if (GetAttributeByUniqueId(dracoMesh, attributes.uv, & attr)) {
|
||||
DracoData * texData = null;
|
||||
if (GetAttributeData(dracoMesh, attr, & texData)) {
|
||||
elementSize =
|
||||
DataTypeSize((GLTFUtilityDracoLoader.DataType) texData -> dataType) *
|
||||
attr -> numComponents;
|
||||
mesh.uv = new Vector2[dracoMesh -> numVertices];
|
||||
var newUVsPtr = UnsafeUtility.AddressOf(ref mesh.uv[0]);
|
||||
UnsafeUtility.MemCpy(newUVsPtr, (void * ) texData -> data,
|
||||
dracoMesh -> numVertices * elementSize);
|
||||
ReleaseDracoData( & texData);
|
||||
ReleaseDracoAttribute( & attr);
|
||||
}
|
||||
}
|
||||
|
||||
// Copy colors.
|
||||
if (GetAttributeByUniqueId(dracoMesh, attributes.col, & attr)) {
|
||||
DracoData * colorData = null;
|
||||
if (GetAttributeData(dracoMesh, attr, & colorData)) {
|
||||
elementSize =
|
||||
DataTypeSize((GLTFUtilityDracoLoader.DataType) colorData -> dataType) *
|
||||
attr -> numComponents;
|
||||
mesh.colors = new Color[dracoMesh -> numVertices];
|
||||
var newColorsPtr = UnsafeUtility.AddressOf(ref mesh.colors[0]);
|
||||
UnsafeUtility.MemCpy(newColorsPtr, (void * ) colorData -> data,
|
||||
dracoMesh -> numVertices * elementSize);
|
||||
ReleaseDracoData( & colorData);
|
||||
ReleaseDracoAttribute( & attr);
|
||||
}
|
||||
}
|
||||
|
||||
// Copy weights.
|
||||
Vector4[] weights = null;
|
||||
if (GetAttributeByUniqueId(dracoMesh, attributes.weights, & attr)) {
|
||||
DracoData * weightData = null;
|
||||
if (GetAttributeData(dracoMesh, attr, & weightData)) {
|
||||
elementSize =
|
||||
DataTypeSize((GLTFUtilityDracoLoader.DataType) weightData -> dataType) *
|
||||
attr -> numComponents;
|
||||
if (attr -> dataType == 9) {
|
||||
weights = new Vector4[dracoMesh -> numVertices];
|
||||
var newWeightsPtr = UnsafeUtility.AddressOf(ref weights[0]);
|
||||
UnsafeUtility.MemCpy(newWeightsPtr, (void * ) weightData -> data,
|
||||
dracoMesh -> numVertices * elementSize);
|
||||
} else if (attr -> dataType == 4) {
|
||||
var newWeightsInt = new Vector4<UInt16>[dracoMesh -> numVertices];
|
||||
var newWeightsPtr = UnsafeUtility.AddressOf(ref newWeightsInt[0]);
|
||||
UnsafeUtility.MemCpy(newWeightsPtr, (void * ) weightData -> data,
|
||||
dracoMesh -> numVertices * elementSize);
|
||||
weights = newWeightsInt.Select(x => new Vector4(x.x, x.y, x.z, x.w)).ToArray();
|
||||
}
|
||||
|
||||
ReleaseDracoData( & weightData);
|
||||
ReleaseDracoAttribute( & attr);
|
||||
}
|
||||
}
|
||||
|
||||
// Copy joints.
|
||||
Vector4[] joints = null;
|
||||
if (GetAttributeByUniqueId(dracoMesh, attributes.joints, & attr)) {
|
||||
DracoData * jointData = null;
|
||||
if (GetAttributeData(dracoMesh, attr, & jointData)) {
|
||||
elementSize =
|
||||
DataTypeSize((GLTFUtilityDracoLoader.DataType) jointData -> dataType) *
|
||||
attr -> numComponents;
|
||||
if (attr -> dataType == 9) {
|
||||
joints = new Vector4[dracoMesh -> numVertices];
|
||||
var newJointsPtr = UnsafeUtility.AddressOf(ref joints[0]);
|
||||
UnsafeUtility.MemCpy(newJointsPtr, (void * ) jointData -> data,
|
||||
dracoMesh -> numVertices * elementSize);
|
||||
} else if (attr -> dataType == 4) {
|
||||
var newJointsInt = new Vector4<UInt16>[dracoMesh -> numVertices];
|
||||
var newJointsPtr = UnsafeUtility.AddressOf(ref newJointsInt[0]);
|
||||
UnsafeUtility.MemCpy(newJointsPtr, (void * ) jointData -> data,
|
||||
dracoMesh -> numVertices * elementSize);
|
||||
joints = newJointsInt.Select(x => new Vector4(x.x, x.y, x.z, x.w)).ToArray();
|
||||
}
|
||||
|
||||
ReleaseDracoData( & jointData);
|
||||
ReleaseDracoAttribute( & attr);
|
||||
}
|
||||
}
|
||||
|
||||
/* #if UNITY_2017_3_OR_NEWER
|
||||
mesh.indexFormat = (newVertices.Length > System.UInt16.MaxValue) ?
|
||||
UnityEngine.Rendering.IndexFormat.UInt32 :
|
||||
UnityEngine.Rendering.IndexFormat.UInt16;
|
||||
#else
|
||||
if (newVertices.Length > System.UInt16.MaxValue) {
|
||||
throw new System.Exception("Draco meshes with more than 65535 vertices are only supported from Unity 2017.3 onwards.");
|
||||
}
|
||||
#endif */
|
||||
|
||||
if (joints != null && weights != null) {
|
||||
if (joints.Length == weights.Length) {
|
||||
BoneWeight[] boneWeights = new BoneWeight[weights.Length];
|
||||
for (int k = 0; k < boneWeights.Length; k++) {
|
||||
NormalizeWeights(ref weights[k]);
|
||||
boneWeights[k].weight0 = weights[k].x;
|
||||
boneWeights[k].weight1 = weights[k].y;
|
||||
boneWeights[k].weight2 = weights[k].z;
|
||||
boneWeights[k].weight3 = weights[k].w;
|
||||
boneWeights[k].boneIndex0 = Mathf.RoundToInt(joints[k].x);
|
||||
boneWeights[k].boneIndex1 = Mathf.RoundToInt(joints[k].y);
|
||||
boneWeights[k].boneIndex2 = Mathf.RoundToInt(joints[k].z);
|
||||
boneWeights[k].boneIndex3 = Mathf.RoundToInt(joints[k].w);
|
||||
}
|
||||
mesh.boneWeights = boneWeights;
|
||||
} else Debug.LogWarning("Draco: joints and weights not same length. Skipped");
|
||||
}
|
||||
return mesh;
|
||||
}
|
||||
|
||||
public void NormalizeWeights(ref Vector4 weights) {
|
||||
float total = weights.x + weights.y + weights.z + weights.w;
|
||||
if (total == 0) return;
|
||||
float mult = 1f / total;
|
||||
weights.x *= mult;
|
||||
weights.y *= mult;
|
||||
weights.z *= mult;
|
||||
weights.w *= mult;
|
||||
}
|
||||
|
||||
private int DataTypeSize(DataType dt) {
|
||||
switch (dt) {
|
||||
case DataType.DT_INT8:
|
||||
case DataType.DT_UINT8:
|
||||
return 1;
|
||||
case DataType.DT_INT16:
|
||||
case DataType.DT_UINT16:
|
||||
return 2;
|
||||
case DataType.DT_INT32:
|
||||
case DataType.DT_UINT32:
|
||||
return 4;
|
||||
case DataType.DT_INT64:
|
||||
case DataType.DT_UINT64:
|
||||
return 8;
|
||||
case DataType.DT_FLOAT32:
|
||||
return 4;
|
||||
case DataType.DT_FLOAT64:
|
||||
return 8;
|
||||
case DataType.DT_BOOL:
|
||||
return 1;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9ae7413bfd6ce074fb7cba6fd7084137
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/GLTFUtility-master/Plugins/draco/Plugin.meta
Normal file
8
Assets/GLTFUtility-master/Plugins/draco/Plugin.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 18d11bbffc2932d4ba56893397a010a3
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Assets/GLTFUtility-master/Plugins/draco/Plugin/.DS_Store
vendored
Normal file
BIN
Assets/GLTFUtility-master/Plugins/draco/Plugin/.DS_Store
vendored
Normal file
Binary file not shown.
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c3cb3b503c4bf984bbe1663b0b569837
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1e66ee77f23663146833d91c35f5f447
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Binary file not shown.
@@ -0,0 +1,111 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8f770194101f3c74dbae841e6d035437
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
: Any
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
Exclude Android: 0
|
||||
Exclude Editor: 0
|
||||
Exclude Linux: 1
|
||||
Exclude Linux64: 1
|
||||
Exclude LinuxUniversal: 1
|
||||
Exclude OSXUniversal: 1
|
||||
Exclude WebGL: 1
|
||||
Exclude Win: 1
|
||||
Exclude Win64: 1
|
||||
Exclude iOS: 1
|
||||
- first:
|
||||
Android: Android
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: ARM64
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
DefaultValueInitialized: true
|
||||
OS: AnyOS
|
||||
- first:
|
||||
Facebook: Win
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
Facebook: Win64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
Standalone: Linux
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: x86
|
||||
- first:
|
||||
Standalone: Linux64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
Standalone: LinuxUniversal
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
Standalone: OSXUniversal
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
Standalone: Win
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
Standalone: Win64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
WebGL: WebGL
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
iPhone: iOS
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
AddToEmbeddedBinaries: false
|
||||
CompileFlags:
|
||||
FrameworkDependencies:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b751ee480d40a07469cc40242758be26
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Binary file not shown.
@@ -0,0 +1,106 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5e308d63e1079dc46aea7da7c38c52d9
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
: Any
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
Exclude Android: 0
|
||||
Exclude Editor: 0
|
||||
Exclude Linux: 1
|
||||
Exclude Linux64: 1
|
||||
Exclude LinuxUniversal: 1
|
||||
Exclude OSXUniversal: 1
|
||||
Exclude WebGL: 1
|
||||
Exclude Win: 1
|
||||
Exclude Win64: 1
|
||||
Exclude iOS: 1
|
||||
- first:
|
||||
Android: Android
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: ARMv7
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
DefaultValueInitialized: true
|
||||
OS: AnyOS
|
||||
- first:
|
||||
Facebook: Win
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
Facebook: Win64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
Standalone: Linux
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: x86
|
||||
- first:
|
||||
Standalone: Linux64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
Standalone: LinuxUniversal
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
Standalone: OSXUniversal
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
Standalone: Win
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
Standalone: Win64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
iPhone: iOS
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
AddToEmbeddedBinaries: false
|
||||
CompileFlags:
|
||||
FrameworkDependencies:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/GLTFUtility-master/Plugins/draco/Plugin/WSA.meta
Normal file
8
Assets/GLTFUtility-master/Plugins/draco/Plugin/WSA.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c95a7c0947cfb4d12827a5ec576ef93d
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Assets/GLTFUtility-master/Plugins/draco/Plugin/WSA/.DS_Store
vendored
Normal file
BIN
Assets/GLTFUtility-master/Plugins/draco/Plugin/WSA/.DS_Store
vendored
Normal file
Binary file not shown.
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 247f211ed244a5246bd95eb03ef807bd
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Binary file not shown.
@@ -0,0 +1,82 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 25cda0e4b8c73b248a6cc47d8d9a5340
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 1
|
||||
isOverridable: 1
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
: Any
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
Exclude Android: 1
|
||||
Exclude Editor: 1
|
||||
Exclude Linux64: 1
|
||||
Exclude OSXUniversal: 1
|
||||
Exclude WebGL: 1
|
||||
Exclude Win: 1
|
||||
Exclude Win64: 1
|
||||
Exclude WindowsStoreApps: 0
|
||||
- first:
|
||||
Android: Android
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: ARMv7
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
DefaultValueInitialized: true
|
||||
OS: AnyOS
|
||||
- first:
|
||||
Standalone: Linux64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
Standalone: OSXUniversal
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
Standalone: Win
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
Standalone: Win64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
Windows Store Apps: WindowsStoreApps
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: ARM
|
||||
DontProcess: false
|
||||
PlaceholderPath:
|
||||
SDK: UWP
|
||||
ScriptingBackend: AnyScriptingBackend
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6fd9b1242506f2242b7f0aea747d003a
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Binary file not shown.
@@ -0,0 +1,82 @@
|
||||
fileFormatVersion: 2
|
||||
guid: da68c67391c543b46a4f57aa2829f479
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 1
|
||||
isOverridable: 1
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
: Any
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
Exclude Android: 1
|
||||
Exclude Editor: 1
|
||||
Exclude Linux64: 1
|
||||
Exclude OSXUniversal: 1
|
||||
Exclude WebGL: 1
|
||||
Exclude Win: 1
|
||||
Exclude Win64: 1
|
||||
Exclude WindowsStoreApps: 0
|
||||
- first:
|
||||
Android: Android
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: ARMv7
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
DefaultValueInitialized: true
|
||||
OS: AnyOS
|
||||
- first:
|
||||
Standalone: Linux64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
Standalone: OSXUniversal
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
Standalone: Win
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
Standalone: Win64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
Windows Store Apps: WindowsStoreApps
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: ARM64
|
||||
DontProcess: false
|
||||
PlaceholderPath:
|
||||
SDK: UWP
|
||||
ScriptingBackend: AnyScriptingBackend
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: adb1df6c7d8b745eeb059f01399eaec2
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Binary file not shown.
@@ -0,0 +1,82 @@
|
||||
fileFormatVersion: 2
|
||||
guid: aa9edc03c58e1498f9df11817c09261d
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 1
|
||||
isOverridable: 1
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
: Any
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
Exclude Android: 1
|
||||
Exclude Editor: 1
|
||||
Exclude Linux64: 1
|
||||
Exclude OSXUniversal: 1
|
||||
Exclude WebGL: 1
|
||||
Exclude Win: 1
|
||||
Exclude Win64: 1
|
||||
Exclude WindowsStoreApps: 0
|
||||
- first:
|
||||
Android: Android
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: ARMv7
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
DefaultValueInitialized: true
|
||||
OS: AnyOS
|
||||
- first:
|
||||
Standalone: Linux64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
Standalone: OSXUniversal
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
Standalone: Win
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
Standalone: Win64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
Windows Store Apps: WindowsStoreApps
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: X64
|
||||
DontProcess: false
|
||||
PlaceholderPath:
|
||||
SDK: UWP
|
||||
ScriptingBackend: AnyScriptingBackend
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 55a5c1975a4d44616a048ba97f60ea08
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Binary file not shown.
@@ -0,0 +1,82 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 22e980b26ccee44528d4c7fe7c6d781c
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 1
|
||||
isOverridable: 1
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
: Any
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
Exclude Android: 1
|
||||
Exclude Editor: 1
|
||||
Exclude Linux64: 1
|
||||
Exclude OSXUniversal: 1
|
||||
Exclude WebGL: 1
|
||||
Exclude Win: 1
|
||||
Exclude Win64: 1
|
||||
Exclude WindowsStoreApps: 0
|
||||
- first:
|
||||
Android: Android
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: ARMv7
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
DefaultValueInitialized: true
|
||||
OS: AnyOS
|
||||
- first:
|
||||
Standalone: Linux64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
Standalone: OSXUniversal
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
Standalone: Win
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
Standalone: Win64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
Windows Store Apps: WindowsStoreApps
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: X86
|
||||
DontProcess: false
|
||||
PlaceholderPath:
|
||||
SDK: UWP
|
||||
ScriptingBackend: AnyScriptingBackend
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,33 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9aeebcdf335a6df429eab3d69d0159ea
|
||||
folderAsset: yes
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
- first:
|
||||
Standalone: OSXUniversal
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e35a9a45f14c2b24f9c82a36f5799410
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,46 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>BuildMachineOSBuild</key>
|
||||
<string>19D76</string>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>English</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>dracodec_unity</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleLongVersionString</key>
|
||||
<string></string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleSupportedPlatforms</key>
|
||||
<array>
|
||||
<string>MacOSX</string>
|
||||
</array>
|
||||
<key>CFBundleVersion</key>
|
||||
<string></string>
|
||||
<key>CSResourcesFileMapped</key>
|
||||
<true/>
|
||||
<key>DTCompiler</key>
|
||||
<string>com.apple.compilers.llvm.clang.1_0</string>
|
||||
<key>DTPlatformBuild</key>
|
||||
<string>11C505</string>
|
||||
<key>DTPlatformVersion</key>
|
||||
<string>GM</string>
|
||||
<key>DTSDKBuild</key>
|
||||
<string>19B90</string>
|
||||
<key>DTSDKName</key>
|
||||
<string>macosx10.15</string>
|
||||
<key>DTXcode</key>
|
||||
<string>1131</string>
|
||||
<key>DTXcodeBuild</key>
|
||||
<string>11C505</string>
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
<string>10.15</string>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
<string></string>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3e981ecc91dd4264397170fc0e11094a
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ddc66c343ee12204897fdd1cd124374e
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Binary file not shown.
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0f3e5b8d3810fb1449e0638febb320ff
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Binary file not shown.
@@ -0,0 +1,81 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3adca5d522c7e4947b2e025441e049ec
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
: Any
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
Exclude Android: 1
|
||||
Exclude Editor: 0
|
||||
Exclude Linux64: 0
|
||||
Exclude Lumin: 1
|
||||
Exclude OSXUniversal: 0
|
||||
Exclude Win: 0
|
||||
Exclude Win64: 0
|
||||
Exclude iOS: 1
|
||||
- first:
|
||||
Android: Android
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: ARMv7
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: x86_64
|
||||
DefaultValueInitialized: true
|
||||
OS: Windows
|
||||
- first:
|
||||
Standalone: Linux64
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
Standalone: OSXUniversal
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
Standalone: Win
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: x86
|
||||
- first:
|
||||
Standalone: Win64
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: x86_64
|
||||
- first:
|
||||
iPhone: iOS
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
AddToEmbeddedBinaries: false
|
||||
CPU: AnyCPU
|
||||
CompileFlags:
|
||||
FrameworkDependencies:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/GLTFUtility-master/Plugins/draco/Plugin/iOS.meta
Normal file
8
Assets/GLTFUtility-master/Plugins/draco/Plugin/iOS.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 87b9e1a9162c1494fa72ad3510b7f7db
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Assets/GLTFUtility-master/Plugins/draco/Plugin/iOS/libdraco.a
Normal file
BIN
Assets/GLTFUtility-master/Plugins/draco/Plugin/iOS/libdraco.a
Normal file
Binary file not shown.
@@ -0,0 +1,80 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5f98a4463b98349d3877f4d34436135c
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
: Any
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
Exclude Android: 1
|
||||
Exclude Editor: 0
|
||||
Exclude Linux64: 1
|
||||
Exclude OSXUniversal: 1
|
||||
Exclude Win: 1
|
||||
Exclude Win64: 1
|
||||
Exclude iOS: 0
|
||||
- first:
|
||||
Android: Android
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: ARMv7
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
DefaultValueInitialized: true
|
||||
OS: AnyOS
|
||||
- first:
|
||||
Standalone: Linux64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
Standalone: OSXUniversal
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
Standalone: Win
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
Standalone: Win64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
iPhone: iOS
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
AddToEmbeddedBinaries: false
|
||||
CPU: AnyCPU
|
||||
CompileFlags:
|
||||
FrameworkDependencies:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Binary file not shown.
@@ -0,0 +1,80 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3d09dcb22c3cf4450815b0e84edd68e3
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
: Any
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
Exclude Android: 1
|
||||
Exclude Editor: 0
|
||||
Exclude Linux64: 1
|
||||
Exclude OSXUniversal: 1
|
||||
Exclude Win: 1
|
||||
Exclude Win64: 1
|
||||
Exclude iOS: 0
|
||||
- first:
|
||||
Android: Android
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: ARMv7
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
DefaultValueInitialized: true
|
||||
OS: AnyOS
|
||||
- first:
|
||||
Standalone: Linux64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
Standalone: OSXUniversal
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
Standalone: Win
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
Standalone: Win64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
iPhone: iOS
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
AddToEmbeddedBinaries: false
|
||||
CPU: AnyCPU
|
||||
CompileFlags:
|
||||
FrameworkDependencies:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
120
Assets/GLTFUtility-master/Plugins/draco/README.md
Normal file
120
Assets/GLTFUtility-master/Plugins/draco/README.md
Normal file
@@ -0,0 +1,120 @@
|
||||
Description
|
||||
===========
|
||||
|
||||
This folder contains resources for building a simple demo decompressing and rendering Draco within Unity.
|
||||
|
||||
If you are looking for more information on using Draco within Unity, this site [https://gitlab.com/atteneder/DracoUnity](https://gitlab.com/atteneder/DracoUnity) is a much better resource. There are more samples as well as support for more platforms.
|
||||
|
||||
In this folder we currently support two types of usages:
|
||||
* Import Draco compressed mesh as assets during design time.
|
||||
* Load/decode Draco files in runtime.
|
||||
|
||||
Prerequisite
|
||||
============
|
||||
|
||||
To start, you need to have the Draco unity plugin. You can either use the
|
||||
prebuilt libraries provided in this folder or build from source.
|
||||
Note that the plugin library for different platforms has different file extension.
|
||||
|
||||
| Platform | Library name |
|
||||
| -------- | ------------ |
|
||||
| Mac OS | dracodec_unity.bundle |
|
||||
| Android | libdracodec_unity.so |
|
||||
| Windows | dracodec_unity.dll |
|
||||
|
||||
Prebuilt Library
|
||||
----------------
|
||||
|
||||
We have built library for several platforms:
|
||||
|
||||
| Platform | Tested Environment |
|
||||
| -------- | ------------------ |
|
||||
| .bundle | macOS Sierra + Xcode 8.3.3 |
|
||||
| armeabi-v7a(.so) | Android 8.1.0 |
|
||||
| .dll | Win10 + Visual Studio 2017 |
|
||||
|
||||
Build From Source
|
||||
-----------------
|
||||
See [BUILDING.md](BUILDING.md) for information on building Draco Unity plug-ins from source.
|
||||
|
||||
Create Draco Demo Unity Project
|
||||
===============================
|
||||
|
||||
Create a new 3D project in Unity.
|
||||
|
||||
Copy Library to Your Project
|
||||
----------------------------
|
||||
Copy the plugin library to your Unity project in `Assets/Plugins/`.
|
||||
For Android Arm7:
|
||||
|
||||
~~~~ bash
|
||||
cp path/to/your/libdracodec_unity.so path/to/your/Unity/Project/Assets/Plugins/Android/libs/armeabi-v7a/
|
||||
~~~~
|
||||
|
||||
For Android Arm8:
|
||||
|
||||
~~~~ bash
|
||||
cp path/to/your/libdracodec_unity.so path/to/your/Unity/Project/Assets/Plugins/Android/libs/arm64-v8a/
|
||||
~~~~
|
||||
|
||||
For Mac:
|
||||
|
||||
~~~~ bash
|
||||
cp path/to/your/dracodec_unity.bundle path/to/your/Unity/Project/Assets/Plugins/
|
||||
~~~~
|
||||
|
||||
For Win:
|
||||
|
||||
~~~~ bash
|
||||
cp path/to/your/dracodec_unity.dll path/to/your/Unity/Project/Assets/Plugins/
|
||||
~~~~
|
||||
|
||||
|
||||
Copy Unity Scripts to Your Project
|
||||
----------------------------------
|
||||
|
||||
~~~~ bash
|
||||
cp unity/DracoDecodingObject.cs path/to/your/Unity/Project/Assets/
|
||||
cp unity/DracoMeshLoader.cs path/to/your/Unity/Project/Assets/
|
||||
~~~~
|
||||
|
||||
Player Settings Change
|
||||
-------------------------------
|
||||
Open player settings. Make sure `Allow unsafe code` is checked, so Unity can load our plug-ins.
|
||||
|
||||
Copy Draco Mesh to Your Project
|
||||
-------------------------------
|
||||
Because Unity can only recognize file extensions known to Unity, you need to change your compressed .drc file to .drc.bytes so that Unity will recognize it as a binary file. For example, if you have file `bunny.drc` then change the file name to `bunny.drc.bytes`.
|
||||
|
||||
~~~~ bash
|
||||
cp path/to/your/bunny.drc path/to/your/Unity/Project/Assets/Resources/bunny.drc.bytes
|
||||
~~~~
|
||||
|
||||
|
||||
---
|
||||
|
||||
Load Draco Assets in Runtime
|
||||
============================
|
||||
For example, please see [DracoDecodingObject.cs](DracoDecodingObject.cs) for usage. To start, you can create an empty GameObject and attach this script to it. [DracoDecodingObject.cs](DracoDecodingObject.cs) will load `bunny.drc.bytes` by default.
|
||||
|
||||
Enable Library in Script Debugging
|
||||
----------------------------------
|
||||
If you have library for the platform you are working on, e.g. `dracodec_unity.bundle` for Mac or `dracodec_unity.dll` for Windows. You should be able to use the plugin in debugging mode.
|
||||
|
||||
---
|
||||
|
||||
Import Compressed Draco Assets
|
||||
==============================
|
||||
In this section we will describe how to import Draco files (.drc) to Unity as
|
||||
other 3D formats at design time, e.g. obj, fbx.
|
||||
Note that importing Draco files doesn't mean the Unity project will export models as Draco files.
|
||||
|
||||
Copy [DracoFileImporter.cs](Editor/DracoFileImporter.cs) which enables loading (This file is only used for import Draco files):
|
||||
|
||||
~~~~ bash
|
||||
cp DracoFileImporter.cs path/to/your/Unity/Project/Assets/Editor/
|
||||
~~~~
|
||||
|
||||
If you have followed the previous steps, you just need to copy your asset, e.g. `bunny.drc.bytes`, to `Your/Unity/Project/Assets/Resources`, the project will automatically load the file and add the models to the project.
|
||||
|
||||
---
|
||||
7
Assets/GLTFUtility-master/Plugins/draco/README.md.meta
Normal file
7
Assets/GLTFUtility-master/Plugins/draco/README.md.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bdcb6b59a16a4e74abea0baf0d380da5
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
112
Assets/GLTFUtility-master/README.md
Normal file
112
Assets/GLTFUtility-master/README.md
Normal file
@@ -0,0 +1,112 @@
|
||||
[](https://discord.gg/qgPrHv4)
|
||||
[](https://github.com/Siccity/GLTFUtility/issues)
|
||||
[](https://raw.githubusercontent.com/Siccity/GLTFUtility/master/LICENSE.md)
|
||||
|
||||
## GLTFUtility
|
||||
Allows you to import and export glTF files during runtime and in editor.
|
||||
glTF is a new opensource 3d model transmission format which supports everything you'll ever need from a format in Unity.
|
||||
[Read more about glTF here](https://www.khronos.org/gltf/)
|
||||
|
||||

|
||||

|
||||

|
||||
|
||||
|
||||
### What makes GLTFUtility different?
|
||||
Focusing on simplicity and ease of use, GLTFUtility aims to be an import-and-forget solution, keeping consistency with built-in functionality.
|
||||
|
||||
### Installation
|
||||
<details><summary>Using Unity Package Manager (<a href="https://docs.unity3d.com/Manual/upm-git.html">Help</a>)</summary>
|
||||
|
||||
1. `"com.siccity.gltfutility": "https://github.com/siccity/gltfutility.git"`
|
||||
</details>
|
||||
<details><summary>Using git</summary>
|
||||
|
||||
1. Get Newtonsoft.JSON from one of these sources
|
||||
* Official upm package: `"com.unity.nuget.newtonsoft-json": "2.0.0-preview"`,
|
||||
* Unofficial git repo: https://github.com/jilleJr/Newtonsoft.Json-for-Unity
|
||||
2. Clone GLTFUtility by itself or as a submodule
|
||||
* Clone into your assets folder `git clone git@github.com:Siccity/GLTFUtility.git`
|
||||
* Add repo as submodule `git submodule add git@github.com:Siccity/GLTFUtility.git Assets/Submodules/GLTFUtility`
|
||||
</details>
|
||||
<details><summary>Manual download</summary>
|
||||
|
||||
1. Get [Newtonsoft.JSON](https://assetstore.unity.com/packages/tools/input-management/json-net-for-unity-11347) from the asset store
|
||||
2. Download [GLTFUtility-master.zip](https://github.com/Siccity/GLTFUtility/archive/master.zip) and extract to your project assets
|
||||
</details>
|
||||
|
||||
[Important notice](https://github.com/Siccity/GLTFUtility#Important-shader-note)
|
||||
|
||||
### Features
|
||||
*System*
|
||||
- [x] Editor import
|
||||
- [ ] Editor export
|
||||
- [x] Runtime import API
|
||||
- [ ] Runtime export API
|
||||
- [x] GLTF format
|
||||
- [x] GLB format
|
||||
- [x] Multithreading
|
||||
- [x] URP [#75](https://github.com/Siccity/GLTFUtility/issues/75)
|
||||
- [ ] HDRP [#73](https://github.com/Siccity/GLTFUtility/issues/73)
|
||||
- [ ] LWRP
|
||||
|
||||
*Spec*
|
||||
- [x] Static mesh (with submeshes)
|
||||
- [x] UVs (up to 8 channels)
|
||||
- [x] Normals
|
||||
- [x] Tangents
|
||||
- [x] Vertex colors
|
||||
- [x] Materials (metallic/specular, opaque/mask/blend)
|
||||
- [x] Textures (embedded/external)
|
||||
- [x] Remote textures (during async only)
|
||||
- [x] Rig
|
||||
- [ ] Avatar/Mask [#70](https://github.com/Siccity/GLTFUtility/issues/70)
|
||||
- [x] Animations (multiple)
|
||||
- [x] Morph targets (with experimental names)
|
||||
- [x] Cameras
|
||||
|
||||
*Extensions*
|
||||
- [x] KHR_texture_transform (partial support)
|
||||
- [x] KHR_materials_pbrSpecularGlossiness
|
||||
- [ ] KHR_lights_punctual [#25](https://github.com/Siccity/GLTFUtility/issues/25)
|
||||
- [x] KHR_draco_mesh_compression [#27](https://github.com/Siccity/GLTFUtility/issues/27) WARNING: Said to cause issues on WebGL.
|
||||
- [x] KHR_mesh_quantization
|
||||
|
||||
### Known issues
|
||||
* `ArgumentNullException: Value cannot be null` in build but not in editor.
|
||||
* This is most likely due to shaders being stripped from the build. To fix this, add the GLTFUtility shaders to the Always Included Shaders list in Graphic Settings.
|
||||
* Draco compression does not work on iOS and UWP
|
||||
* More info on [#133](https://github.com/Siccity/GLTFUtility/issues/133)
|
||||
|
||||
### Runtime import API
|
||||
```cs
|
||||
// Single thread
|
||||
using Siccity.GLTFUtility;
|
||||
|
||||
void ImportGLTF(string filepath) {
|
||||
GameObject result = Importer.LoadFromFile(filepath);
|
||||
}
|
||||
```
|
||||
```cs
|
||||
// Multithreaded
|
||||
using Siccity.GLTFUtility;
|
||||
|
||||
void ImportGLTFAsync(string filepath) {
|
||||
Importer.ImportGLTFAsync(filepath, new ImportSettings(), OnFinishAsync);
|
||||
}
|
||||
|
||||
void OnFinishAsync(GameObject result, AnimationClip[] animations) {
|
||||
Debug.Log("Finished importing " + result.name);
|
||||
}
|
||||
```
|
||||
|
||||
### Important shader note
|
||||
To ensure that Unity includes the GLTFUtility shaders in builds, you must add these shaders to the 'Always Included Shaders' list.
|
||||
|
||||
1. Open Edit -> Project Settings
|
||||
2. Open Graphics
|
||||
3. Scroll to Always Included Shaders
|
||||
4. Under Size, increase the value by 4 and hit Enter.
|
||||
5. In the Project panel, navigate to Packages/GLTFUtility/Materials/Built-in.
|
||||
6. In this directory are 4 .shader files.
|
||||
7. Drag and drop each of the 4 files into one of the 4 newly created rows in Always Included Shaders.
|
||||
7
Assets/GLTFUtility-master/README.md.meta
Normal file
7
Assets/GLTFUtility-master/README.md.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a375268139388f44fa7e4f7cc8f8729d
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
10
Assets/GLTFUtility-master/Scripts.meta
Normal file
10
Assets/GLTFUtility-master/Scripts.meta
Normal file
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1a53c6d71b38ddd45974d563dc47f847
|
||||
folderAsset: yes
|
||||
timeCreated: 1538919605
|
||||
licenseType: Free
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Assets/GLTFUtility-master/Scripts/.DS_Store
vendored
Normal file
BIN
Assets/GLTFUtility-master/Scripts/.DS_Store
vendored
Normal file
Binary file not shown.
122
Assets/GLTFUtility-master/Scripts/BufferedBinaryReader.cs
Normal file
122
Assets/GLTFUtility-master/Scripts/BufferedBinaryReader.cs
Normal file
@@ -0,0 +1,122 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using UnityEngine;
|
||||
|
||||
// This is a modified version of the script from: https://jacksondunstan.com/articles/3568
|
||||
/// <summary> Much faster than BinaryReader </summary>
|
||||
public class BufferedBinaryReader : IDisposable {
|
||||
private readonly Stream stream;
|
||||
private readonly byte[] buffer;
|
||||
private readonly int bufferSize;
|
||||
private int bufferOffset;
|
||||
private int bufferedBytes;
|
||||
private int byteStride;
|
||||
|
||||
private Bit2Converter bit2Converter;
|
||||
private Bit4Converter bit4Converter;
|
||||
|
||||
public long Position { get { return stream.Position + bufferOffset; } set { stream.Position = value; bufferedBytes = 0; bufferOffset = 0; } }
|
||||
|
||||
public BufferedBinaryReader(Stream stream, int bufferSize) {
|
||||
this.stream = stream;
|
||||
this.bufferSize = bufferSize;
|
||||
buffer = new byte[bufferSize];
|
||||
bufferOffset = 0;
|
||||
bufferedBytes = 0;
|
||||
}
|
||||
|
||||
private void FillBuffer(int byteCount) {
|
||||
int unreadBytes = bufferedBytes - bufferOffset;
|
||||
|
||||
if (unreadBytes < byteCount) {
|
||||
// If not enough bytes left in buffer
|
||||
if (unreadBytes != 0) {
|
||||
// If buffer still has unread bytes, move them to start of buffer
|
||||
Buffer.BlockCopy(buffer, bufferOffset, buffer, 0, unreadBytes);
|
||||
}
|
||||
bufferedBytes = stream.Read(buffer, unreadBytes, bufferSize - unreadBytes) + unreadBytes;
|
||||
bufferOffset = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public byte ReadByte() {
|
||||
FillBuffer(1);
|
||||
return buffer[bufferOffset++];
|
||||
}
|
||||
|
||||
public sbyte ReadSByte() {
|
||||
FillBuffer(1);
|
||||
return (sbyte) buffer[bufferOffset++];
|
||||
}
|
||||
|
||||
public ushort ReadUInt16() {
|
||||
FillBuffer(sizeof(ushort));
|
||||
return bit2Converter.Read(buffer, ref bufferOffset).@ushort;
|
||||
}
|
||||
|
||||
public short ReadInt16() {
|
||||
FillBuffer(sizeof(short));
|
||||
return bit2Converter.Read(buffer, ref bufferOffset).@short;
|
||||
}
|
||||
|
||||
public uint ReadUInt32() {
|
||||
FillBuffer(sizeof(uint));
|
||||
return bit4Converter.Read(buffer, ref bufferOffset).@uint;
|
||||
}
|
||||
|
||||
public int ReadInt32() {
|
||||
FillBuffer(sizeof(int));
|
||||
return bit4Converter.Read(buffer, ref bufferOffset).@int;
|
||||
}
|
||||
|
||||
public float ReadSingle() {
|
||||
FillBuffer(sizeof(float));
|
||||
return bit4Converter.Read(buffer, ref bufferOffset).@float;
|
||||
}
|
||||
|
||||
public void Skip(int bytes) {
|
||||
FillBuffer(bytes);
|
||||
bufferOffset += bytes;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Explicit)]
|
||||
public struct Bit2Converter {
|
||||
[FieldOffset(0)] public byte b0;
|
||||
[FieldOffset(1)] public byte b1;
|
||||
[FieldOffset(0)] public short @short;
|
||||
[FieldOffset(0)] public ushort @ushort;
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public Bit2Converter Read(byte[] buffer, ref int bufferOffset) {
|
||||
b0 = buffer[bufferOffset++];
|
||||
b1 = buffer[bufferOffset++];
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Explicit)]
|
||||
public struct Bit4Converter {
|
||||
[FieldOffset(0)] public byte b0;
|
||||
[FieldOffset(1)] public byte b1;
|
||||
[FieldOffset(2)] public byte b2;
|
||||
[FieldOffset(3)] public byte b3;
|
||||
[FieldOffset(0)] public float @float;
|
||||
[FieldOffset(0)] public int @int;
|
||||
[FieldOffset(0)] public uint @uint;
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public Bit4Converter Read(byte[] buffer, ref int bufferOffset) {
|
||||
b0 = buffer[bufferOffset++];
|
||||
b1 = buffer[bufferOffset++];
|
||||
b2 = buffer[bufferOffset++];
|
||||
b3 = buffer[bufferOffset++];
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose() {
|
||||
stream.Close();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3c0ec98d1cbd7324cbe265d9819a7b11
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/GLTFUtility-master/Scripts/Converters.meta
Normal file
8
Assets/GLTFUtility-master/Scripts/Converters.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6f0a1eaa625f4834c98391d4025b2fa2
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,48 @@
|
||||
using System;
|
||||
using Newtonsoft.Json;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Scripting;
|
||||
|
||||
namespace Siccity.GLTFUtility.Converters {
|
||||
/// <summary> Converts from float array to Color during deserialization, and back </summary>
|
||||
[Preserve] public class ColorRGBConverter : JsonConverter {
|
||||
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) {
|
||||
Color c = (Color) value;
|
||||
writer.WriteStartArray();
|
||||
writer.WriteValue(c.r);
|
||||
writer.WriteValue(c.g);
|
||||
writer.WriteValue(c.b);
|
||||
writer.WriteEndArray();
|
||||
}
|
||||
|
||||
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) {
|
||||
float[] a = serializer.Deserialize<float[]>(reader);
|
||||
return new Color(a[0], a[1], a[2]);
|
||||
}
|
||||
|
||||
public override bool CanConvert(Type objectType) {
|
||||
return objectType == typeof(Color);
|
||||
}
|
||||
}
|
||||
|
||||
[Preserve] public class ColorRGBAConverter : JsonConverter {
|
||||
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) {
|
||||
Color c = (Color) value;
|
||||
writer.WriteStartArray();
|
||||
writer.WriteValue(c.r);
|
||||
writer.WriteValue(c.g);
|
||||
writer.WriteValue(c.b);
|
||||
writer.WriteValue(c.a);
|
||||
writer.WriteEndArray();
|
||||
}
|
||||
|
||||
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) {
|
||||
float[] a = serializer.Deserialize<float[]>(reader);
|
||||
return new Color(a[0], a[1], a[2], a[3]);
|
||||
}
|
||||
|
||||
public override bool CanConvert(Type objectType) {
|
||||
return objectType == typeof(Color);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6532df4837460e147922cbb51088800d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user