Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Vision-R-Public
ArchiTOOL
Commits
4ca50734
Commit
4ca50734
authored
Mar 29, 2022
by
Haobo Wang
Browse files
Setup
parent
c1a0abe4
Pipeline
#94866
failed with stage
in 38 seconds
Changes
130
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Operational view/XR Interaction/.vsconfig
0 → 100644
View file @
4ca50734
{
"version": "1.0",
"components": [
"Microsoft.VisualStudio.Workload.ManagedGame"
]
}
Operational view/XR Interaction/Assets/InputSystem.inputsettings.asset
0 → 100644
View file @
4ca50734
%YAML
1.1
%TAG
!u!
tag:unity3d.com,2011:
---
!u!114
&11400000
MonoBehaviour
:
m_ObjectHideFlags
:
0
m_CorrespondingSourceObject
:
{
fileID
:
0
}
m_PrefabInstance
:
{
fileID
:
0
}
m_PrefabAsset
:
{
fileID
:
0
}
m_GameObject
:
{
fileID
:
0
}
m_Enabled
:
1
m_EditorHideFlags
:
0
m_Script
:
{
fileID
:
11500000
,
guid
:
c46f07b5ed07e4e92aa78254188d3d10
,
type
:
3
}
m_Name
:
InputSystem.inputsettings
m_EditorClassIdentifier
:
m_SupportedDevices
:
[]
m_UpdateMode
:
1
m_MaxEventBytesPerUpdate
:
5242880
m_MaxQueuedEventsPerUpdate
:
1000
m_CompensateForScreenOrientation
:
1
m_FilterNoiseOnCurrent
:
0
m_BackgroundBehavior
:
0
m_EditorInputBehaviorInPlayMode
:
0
m_DefaultDeadzoneMin
:
0.125
m_DefaultDeadzoneMax
:
0.925
m_DefaultButtonPressPoint
:
0.5
m_ButtonReleaseThreshold
:
0.75
m_DefaultTapTime
:
0.2
m_DefaultSlowTapTime
:
0.5
m_DefaultHoldTime
:
0.4
m_TapRadius
:
5
m_MultiTapDelayTime
:
0.75
m_DisableRedundantEventsMerging
:
0
m_iOSSettings
:
m_MotionUsage
:
m_Enabled
:
0
m_Description
:
Operational view/XR Interaction/Assets/InputSystem.inputsettings.asset.meta
0 → 100644
View file @
4ca50734
fileFormatVersion: 2
guid: c5c1b451c3a868a4f998be67248b8a5a
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:
Operational view/XR Interaction/Assets/OBJImport.meta
0 → 100644
View file @
4ca50734
fileFormatVersion: 2
guid: 9ce4666d1148aea42aca2d54d33a6e9c
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
Operational view/XR Interaction/Assets/OBJImport/CharWordReader.cs
0 → 100644
View file @
4ca50734
using
System.Collections
;
using
System.Collections.Generic
;
using
UnityEngine
;
using
System.IO
;
using
System.Text
;
namespace
Dummiesman
{
public
class
CharWordReader
{
public
char
[]
word
;
public
int
wordSize
;
public
bool
endReached
;
private
StreamReader
reader
;
private
int
bufferSize
;
private
char
[]
buffer
;
public
char
currentChar
;
private
int
currentPosition
=
0
;
private
int
maxPosition
=
0
;
public
CharWordReader
(
StreamReader
reader
,
int
bufferSize
)
{
this
.
reader
=
reader
;
this
.
bufferSize
=
bufferSize
;
this
.
buffer
=
new
char
[
this
.
bufferSize
];
this
.
word
=
new
char
[
this
.
bufferSize
];
this
.
MoveNext
();
}
public
void
SkipWhitespaces
()
{
while
(
char
.
IsWhiteSpace
(
this
.
currentChar
))
{
this
.
MoveNext
();
}
}
public
void
SkipWhitespaces
(
out
bool
newLinePassed
)
{
newLinePassed
=
false
;
while
(
char
.
IsWhiteSpace
(
this
.
currentChar
))
{
if
(
this
.
currentChar
==
'\r'
||
this
.
currentChar
==
'\n'
)
{
newLinePassed
=
true
;
}
this
.
MoveNext
();
}
}
public
void
SkipUntilNewLine
()
{
while
(
this
.
currentChar
!=
char
.
MinValue
&&
this
.
currentChar
!=
'\n'
&&
this
.
currentChar
!=
'\r'
)
{
this
.
MoveNext
();
}
this
.
SkipNewLineSymbols
();
}
public
void
ReadUntilWhiteSpace
()
{
this
.
wordSize
=
0
;
while
(
this
.
currentChar
!=
char
.
MinValue
&&
char
.
IsWhiteSpace
(
this
.
currentChar
)
==
false
)
{
this
.
word
[
this
.
wordSize
]
=
this
.
currentChar
;
this
.
wordSize
++;
this
.
MoveNext
();
}
}
public
void
ReadUntilNewLine
()
{
this
.
wordSize
=
0
;
while
(
this
.
currentChar
!=
char
.
MinValue
&&
this
.
currentChar
!=
'\n'
&&
this
.
currentChar
!=
'\r'
)
{
this
.
word
[
this
.
wordSize
]
=
this
.
currentChar
;
this
.
wordSize
++;
this
.
MoveNext
();
}
this
.
SkipNewLineSymbols
();
}
public
bool
Is
(
string
other
)
{
if
(
other
.
Length
!=
this
.
wordSize
)
{
return
false
;
}
for
(
int
i
=
0
;
i
<
this
.
wordSize
;
i
++)
{
if
(
this
.
word
[
i
]
!=
other
[
i
])
{
return
false
;
}
}
return
true
;
}
public
string
GetString
(
int
startIndex
=
0
)
{
if
(
startIndex
>=
this
.
wordSize
-
1
)
{
return
string
.
Empty
;
}
return
new
string
(
this
.
word
,
startIndex
,
this
.
wordSize
-
startIndex
);
}
public
Vector3
ReadVector
()
{
this
.
SkipWhitespaces
();
float
x
=
this
.
ReadFloat
();
this
.
SkipWhitespaces
();
float
y
=
this
.
ReadFloat
();
this
.
SkipWhitespaces
(
out
var
newLinePassed
);
float
z
=
0f
;
if
(
newLinePassed
==
false
)
{
z
=
this
.
ReadFloat
();
}
return
new
Vector3
(
x
,
y
,
z
);
}
public
int
ReadInt
()
{
int
result
=
0
;
bool
isNegative
=
this
.
currentChar
==
'-'
;
if
(
isNegative
==
true
)
{
this
.
MoveNext
();
}
while
(
this
.
currentChar
>=
'0'
&&
this
.
currentChar
<=
'9'
)
{
var
digit
=
this
.
currentChar
-
'0'
;
result
=
result
*
10
+
digit
;
this
.
MoveNext
();
}
return
(
isNegative
==
true
)
?
-
result
:
result
;
}
public
float
ReadFloat
()
{
bool
isNegative
=
this
.
currentChar
==
'-'
;
if
(
isNegative
)
{
this
.
MoveNext
();
}
var
num
=
(
float
)
this
.
ReadInt
();
if
(
this
.
currentChar
==
'.'
||
this
.
currentChar
==
','
)
{
this
.
MoveNext
();
num
+=
this
.
ReadFloatEnd
();
if
(
this
.
currentChar
==
'e'
||
this
.
currentChar
==
'E'
)
{
this
.
MoveNext
();
var
exp
=
this
.
ReadInt
();
num
=
num
*
Mathf
.
Pow
(
10f
,
exp
);
}
}
if
(
isNegative
==
true
)
{
num
=
-
num
;
}
return
num
;
}
private
float
ReadFloatEnd
()
{
float
result
=
0f
;
var
exp
=
0.1f
;
while
(
this
.
currentChar
>=
'0'
&&
this
.
currentChar
<=
'9'
)
{
var
digit
=
this
.
currentChar
-
'0'
;
result
+=
digit
*
exp
;
exp
*=
0.1f
;
this
.
MoveNext
();
}
return
result
;
}
private
void
SkipNewLineSymbols
()
{
while
(
this
.
currentChar
==
'\n'
||
this
.
currentChar
==
'\r'
)
{
this
.
MoveNext
();
}
}
public
void
MoveNext
()
{
this
.
currentPosition
++;
if
(
this
.
currentPosition
>=
this
.
maxPosition
)
{
if
(
this
.
reader
.
EndOfStream
==
true
)
{
this
.
currentChar
=
char
.
MinValue
;
this
.
endReached
=
true
;
return
;
}
this
.
currentPosition
=
0
;
this
.
maxPosition
=
this
.
reader
.
Read
(
this
.
buffer
,
0
,
this
.
bufferSize
);
}
this
.
currentChar
=
this
.
buffer
[
this
.
currentPosition
];
}
}
}
\ No newline at end of file
Operational view/XR Interaction/Assets/OBJImport/CharWordReader.cs.meta
0 → 100644
View file @
4ca50734
fileFormatVersion: 2
guid: 37ed5e34a98d98669ac1a63bf547afa3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Operational view/XR Interaction/Assets/OBJImport/MTLLoader.cs
0 → 100644
View file @
4ca50734
/*
* Copyright (c) 2019 Dummiesman
*
* 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.
*/
using
Dummiesman
;
using
System.Collections.Generic
;
using
System.IO
;
using
UnityEngine
;
public
class
MTLLoader
{
public
List
<
string
>
SearchPaths
=
new
List
<
string
>()
{
"%FileName%_Textures"
,
string
.
Empty
};
private
FileInfo
_objFileInfo
=
null
;
/// <summary>
/// The texture loading function. Overridable for stream loading purposes.
/// </summary>
/// <param name="path">The path supplied by the OBJ file, converted to OS path seperation</param>
/// <param name="isNormalMap">Whether the loader is requesting we convert this into a normal map</param>
/// <returns>Texture2D if found, or NULL if missing</returns>
public
virtual
Texture2D
TextureLoadFunction
(
string
path
,
bool
isNormalMap
)
{
//find it
foreach
(
var
searchPath
in
SearchPaths
)
{
//replace varaibles and combine path
string
processedPath
=
(
_objFileInfo
!=
null
)
?
searchPath
.
Replace
(
"%FileName%"
,
Path
.
GetFileNameWithoutExtension
(
_objFileInfo
.
Name
))
:
searchPath
;
string
filePath
=
Path
.
Combine
(
processedPath
,
path
);
//return if eists
if
(
File
.
Exists
(
filePath
))
{
var
tex
=
ImageLoader
.
LoadTexture
(
filePath
);
if
(
isNormalMap
)
tex
=
ImageUtils
.
ConvertToNormalMap
(
tex
);
return
tex
;
}
}
//not found
return
null
;
}
private
Texture2D
TryLoadTexture
(
string
texturePath
,
bool
normalMap
=
false
)
{
//swap directory seperator char
texturePath
=
texturePath
.
Replace
(
'\\'
,
Path
.
DirectorySeparatorChar
);
texturePath
=
texturePath
.
Replace
(
'/'
,
Path
.
DirectorySeparatorChar
);
return
TextureLoadFunction
(
texturePath
,
normalMap
);
}
private
int
GetArgValueCount
(
string
arg
)
{
switch
(
arg
)
{
case
"-bm"
:
case
"-clamp"
:
case
"-blendu"
:
case
"-blendv"
:
case
"-imfchan"
:
case
"-texres"
:
return
1
;
case
"-mm"
:
return
2
;
case
"-o"
:
case
"-s"
:
case
"-t"
:
return
3
;
}
return
-
1
;
}
private
int
GetTexNameIndex
(
string
[]
components
)
{
for
(
int
i
=
1
;
i
<
components
.
Length
;
i
++)
{
var
cmpSkip
=
GetArgValueCount
(
components
[
i
]);
if
(
cmpSkip
<
0
)
{
return
i
;
}
i
+=
cmpSkip
;
}
return
-
1
;
}
private
float
GetArgValue
(
string
[]
components
,
string
arg
,
float
fallback
=
1f
)
{
string
argLower
=
arg
.
ToLower
();
for
(
int
i
=
1
;
i
<
components
.
Length
-
1
;
i
++)
{
var
cmp
=
components
[
i
].
ToLower
();
if
(
argLower
==
cmp
)
{
return
OBJLoaderHelper
.
FastFloatParse
(
components
[
i
+
1
]);
}
}
return
fallback
;
}
private
string
GetTexPathFromMapStatement
(
string
processedLine
,
string
[]
splitLine
)
{
int
texNameCmpIdx
=
GetTexNameIndex
(
splitLine
);
if
(
texNameCmpIdx
<
0
)
{
Debug
.
LogError
(
$"texNameCmpIdx < 0 on line
{
processedLine
}
. Texture not loaded."
);
return
null
;
}
int
texNameIdx
=
processedLine
.
IndexOf
(
splitLine
[
texNameCmpIdx
]);
string
texturePath
=
processedLine
.
Substring
(
texNameIdx
);
return
texturePath
;
}
/// <summary>
/// Loads a *.mtl file
/// </summary>
/// <param name="input">The input stream from the MTL file</param>
/// <returns>Dictionary containing loaded materials</returns>
public
Dictionary
<
string
,
Material
>
Load
(
Stream
input
)
{
var
inputReader
=
new
StreamReader
(
input
);
var
reader
=
new
StringReader
(
inputReader
.
ReadToEnd
());
Dictionary
<
string
,
Material
>
mtlDict
=
new
Dictionary
<
string
,
Material
>();
Material
currentMaterial
=
null
;
for
(
string
line
=
reader
.
ReadLine
();
line
!=
null
;
line
=
reader
.
ReadLine
())
{
if
(
string
.
IsNullOrWhiteSpace
(
line
))
continue
;
string
processedLine
=
line
.
Clean
();
string
[]
splitLine
=
processedLine
.
Split
(
' '
);
//blank or comment
if
(
splitLine
.
Length
<
2
||
processedLine
[
0
]
==
'#'
)
continue
;
//newmtl
if
(
splitLine
[
0
]
==
"newmtl"
)
{
string
materialName
=
processedLine
.
Substring
(
7
);
var
newMtl
=
new
Material
(
Shader
.
Find
(
"Standard (Specular setup)"
))
{
name
=
materialName
};
mtlDict
[
materialName
]
=
newMtl
;
currentMaterial
=
newMtl
;
continue
;
}
//anything past here requires a material instance
if
(
currentMaterial
==
null
)
continue
;
//diffuse color
if
(
splitLine
[
0
]
==
"Kd"
||
splitLine
[
0
]
==
"kd"
)
{
var
currentColor
=
currentMaterial
.
GetColor
(
"_Color"
);
var
kdColor
=
OBJLoaderHelper
.
ColorFromStrArray
(
splitLine
);
currentMaterial
.
SetColor
(
"_Color"
,
new
Color
(
kdColor
.
r
,
kdColor
.
g
,
kdColor
.
b
,
currentColor
.
a
));
continue
;
}
//diffuse map
if
(
splitLine
[
0
]
==
"map_Kd"
||
splitLine
[
0
]
==
"map_kd"
)
{
string
texturePath
=
GetTexPathFromMapStatement
(
processedLine
,
splitLine
);
if
(
texturePath
==
null
)
{
continue
;
//invalid args or sth
}
var
KdTexture
=
TryLoadTexture
(
texturePath
);
currentMaterial
.
SetTexture
(
"_MainTex"
,
KdTexture
);
//set transparent mode if the texture has transparency
if
(
KdTexture
!=
null
&&
(
KdTexture
.
format
==
TextureFormat
.
DXT5
||
KdTexture
.
format
==
TextureFormat
.
ARGB32
))
{
OBJLoaderHelper
.
EnableMaterialTransparency
(
currentMaterial
);
}
//flip texture if this is a dds
if
(
Path
.
GetExtension
(
texturePath
).
ToLower
()
==
".dds"
)
{
currentMaterial
.
mainTextureScale
=
new
Vector2
(
1f
,
-
1f
);
}
continue
;
}
//bump map
if
(
splitLine
[
0
]
==
"map_Bump"
||
splitLine
[
0
]
==
"map_bump"
)
{
string
texturePath
=
GetTexPathFromMapStatement
(
processedLine
,
splitLine
);
if
(
texturePath
==
null
)
{
continue
;
//invalid args or sth
}
var
bumpTexture
=
TryLoadTexture
(
texturePath
,
true
);
float
bumpScale
=
GetArgValue
(
splitLine
,
"-bm"
,
1.0f
);
if
(
bumpTexture
!=
null
)
{
currentMaterial
.
SetTexture
(
"_BumpMap"
,
bumpTexture
);
currentMaterial
.
SetFloat
(
"_BumpScale"
,
bumpScale
);
currentMaterial
.
EnableKeyword
(
"_NORMALMAP"
);
}
continue
;
}
//specular color
if
(
splitLine
[
0
]
==
"Ks"
||
splitLine
[
0
]
==
"ks"
)
{
currentMaterial
.
SetColor
(
"_SpecColor"
,
OBJLoaderHelper
.
ColorFromStrArray
(
splitLine
));
continue
;
}
//emission color
if
(
splitLine
[
0
]
==
"Ka"
||
splitLine
[
0
]
==
"ka"
)
{
currentMaterial
.
SetColor
(
"_EmissionColor"
,
OBJLoaderHelper
.
ColorFromStrArray
(
splitLine
,
0.05f
));
currentMaterial
.
EnableKeyword
(
"_EMISSION"
);
continue
;
}
//emission map
if
(
splitLine
[
0
]
==
"map_Ka"
||
splitLine
[
0
]
==
"map_ka"
)
{
string
texturePath
=
GetTexPathFromMapStatement
(
processedLine
,
splitLine
);
if
(
texturePath
==
null
)
{
continue
;
//invalid args or sth
}
currentMaterial
.
SetTexture
(
"_EmissionMap"
,
TryLoadTexture
(
texturePath
));
continue
;
}
//alpha
if
(
splitLine
[
0
]
==
"d"
||
splitLine
[
0
]
==
"Tr"
)
{
float
visibility
=
OBJLoaderHelper
.
FastFloatParse
(
splitLine
[
1
]);
//tr statement is just d inverted
if
(
splitLine
[
0
]
==
"Tr"
)
visibility
=
1f
-
visibility
;
if
(
visibility
<
(
1f
-
Mathf
.
Epsilon
))
{
var
currentColor
=
currentMaterial
.
GetColor
(
"_Color"
);
currentColor
.
a
=
visibility
;
currentMaterial
.
SetColor
(
"_Color"
,
currentColor
);
OBJLoaderHelper
.
EnableMaterialTransparency
(
currentMaterial
);
}
continue
;
}
//glossiness
if
(
splitLine
[
0
]
==
"Ns"
||
splitLine
[
0
]
==
"ns"
)
{
float
Ns
=
OBJLoaderHelper
.
FastFloatParse
(
splitLine
[
1
]);
Ns
=
(
Ns
/
1000f
);
currentMaterial
.
SetFloat
(
"_Glossiness"
,
Ns
);
}
}
//return our dict
return
mtlDict
;
}
/// <summary>
/// Loads a *.mtl file
/// </summary>
/// <param name="path">The path to the MTL file</param>
/// <returns>Dictionary containing loaded materials</returns>
public
Dictionary
<
string
,
Material
>
Load
(
string
path
)
{
_objFileInfo
=
new
FileInfo
(
path
);
//get file info
SearchPaths
.
Add
(
_objFileInfo
.
Directory
.
FullName
);
//add root path to search dir
using
(
var
fs
=
new
FileStream
(
path
,
FileMode
.
Open
))
{
return
Load
(
fs
);
//actually load
}
}
}
Operational view/XR Interaction/Assets/OBJImport/MTLLoader.cs.meta
0 → 100644
View file @
4ca50734
fileFormatVersion: 2
guid: 11b3883c0720fb8409b86b54877b58ea
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Operational view/XR Interaction/Assets/OBJImport/OBJLoader.cs
0 → 100644