-
Notifications
You must be signed in to change notification settings - Fork 47
/
SceneGraphConfig.cs
190 lines (148 loc) · 6.43 KB
/
SceneGraphConfig.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
using System;
using System.IO;
using System.Collections.Generic;
using UnityEngine;
using g3;
namespace f3
{
public class SavedSettings
{
Dictionary<string, object> settings = new Dictionary<string, object>();
static SavedSettings singleton;
public static SavedSettings Get
{
get { if (singleton == null) singleton = new SavedSettings(); return singleton; }
}
public static void Save(string sName, object value)
{
Get.settings[sName] = value;
}
public static object Restore(string sName)
{
if (Get.settings.ContainsKey(sName))
return Get.settings[sName];
return null;
}
}
public class SceneGraphConfig
{
static string lastFileOpenPath = "c:\\";
protected SceneGraphConfig ()
{
ActiveDoubleClickDelay = MouseDoubleClickDelay;
}
public static string GeometryLayerName {
get { return "Default"; }
}
// assumption is that layer with this name has been created in the Editor, because we
// cannot create layers in code. We will use this layer to draw overlay 3D objects (eg 3D widgets, etc)
public static string WidgetOverlayLayerName {
get { return "3DWidgetOverlay"; }
}
// same as above, overlay for HUD/cockpit
public static string HUDLayerName
{
get { return "HUDOverlay"; }
}
// same as above, overlay for 2D UI
public static string UILayerName
{
get { return "UIOverlay"; }
}
// same as above, overlay for cursor
public static string CursorLayerName
{
get { return "CursorOverlay"; }
}
// for transparent objects, unity Z-sorts by the center of each mesh, which can cause transparent
// things to pop behind/infront objects close to them (eg the background rect for a text field).
// We can tweak this by putting the text in a different z-sorting layer, which is defind by
// Renderer.material.renderQueue.
// details on render queue #'s: https://docs.unity3d.com/Manual/SL-SubShaderTags.html
// (An alternative is to put it in a separate Layer / Sorting Layer, but this is quite heavy and
// we are trying to reserve that for major different layers, because there is no z-testing between them)
// This is the default 'Transparent' renderQueue in Unity, so text will be z-ordered same as opaque elements
public static int TextRendererQueue = 3000;
public static string DefaultStandardMaterialPath
{
get { return "StandardMaterials/default_standard"; }
}
public static string DefaultTransparentMaterialPath {
get { return "StandardMaterials/standard_transparent"; }
}
public static string DefaultUnlitTransparentMaterialPath
{
get { return "StandardMaterials/default_unlit_transparent"; }
}
public static string DefaultUnlitTextureTransparentMaterialPath
{
get { return "StandardMaterials/default_unlit_texture_transparent"; }
}
public static string DefaultUnlitTextureMaterialPath
{
get { return "StandardMaterials/default_unlit_texture"; }
}
public static string DefaultParticleMaterialPath
{
get { return "StandardMaterials/default_particle"; }
}
public static string DefaultDropShadowMaterialPath
{
get { return "StandardMaterials/drop_shadow_mat"; }
}
public static string DefaultDepthWriteOnlyMaterialPath {
get { return "StandardMaterials/depth_write_only"; }
}
public static string LastFileOpenPath
{
get { return lastFileOpenPath; }
set { lastFileOpenPath = value; PlayerPrefs.SetString("LastFileOpenPath", value); }
}
// [RMS] this is what we use for VR scenes...should not be set to this value, probably!!
public static Vector3f InitialSceneTranslate = Vector3f.Zero;
public static float DefaultPivotVisualDegrees = 2.0f;
public static float DefaultAxisGizmoVisualDegrees = 25.0f;
public static float DefaultSnapCurveVisualDegrees = 0.25f;
public static float DefaultSceneCurveVisualDegrees = 1.0f;
public static float DefaultSnapDistVisualDegrees = 5.0f;
// VR "hand" cursor dimensions. You can use these to find different points on
// the arrrows (eg tip is handFrame.Origin + VRHandTipOffset*handFrame.Z)
public static float VRHandTipOffset = 0.1f;
public static float VRHandArrowRadius = 0.1f;
public static float VRHandStickLength = 0.1f;
public static float VRHandStickWidth = 0.05f;
public static bool EnableVisibleCameraPivot = true;
public static float CameraPivotVisualDegrees = 1.0f;
// Default Z-offset for text relative to background rect, used in HUDLabel, HUDTextEntry, etc...
// In 2D, this doesn't matter except that if it is too small there might be Z-fighting, and if
// you have overlapping 2D elements it might make the text poke through.
// In 3D, if it is too large there will be large gaps between text and widgets
// Only used at widget creation time, so you can change it dynamically if need be.
public static float TextLabelZOffset = -0.01f;
// determined by geometry in SpatialInputController.cs
public static float HandTipOffset = 0.1f;
// set this to 0 to disable cursor-hide
public static float MouseCursorHideTimeout {
get { return 5.0f; }
}
public static float MouseDoubleClickDelay {
get { return 0.3f; }
}
public static float TriggerDoubleClickDelay {
get { return 0.4f; }
}
public static float ActiveDoubleClickDelay { get; set; }
public static void ConfigureForVR() {
// bump up text render queue. This means *all* text will be drawn on top of UI elements.
TextRendererQueue = 3100;
}
public static void RestorePreferences()
{
if (PlayerPrefs.HasKey("LastFileOpenPath")) {
string sDir = PlayerPrefs.GetString("LastFileOpenPath");
if (Directory.Exists(sDir))
lastFileOpenPath = sDir;
}
}
}
}