-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhom3r.cs
More file actions
184 lines (158 loc) · 7.92 KB
/
hom3r.cs
File metadata and controls
184 lines (158 loc) · 7.92 KB
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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
static class Constants
{
public const float Pi = 3.14159265359f;
public const bool undoAllowed = true; //Const to store the valueo to allow undo
public const bool undoNotAllowed = false; //Const to store the valueo to not allow undo
public const int largeText = 25; //Const to indicate when a text is considered long
}
static class MathHom3r
{
/// <summary>Calculate Power of two of a float input</summary>
/// <param name="value">float value to power two</param>
/// <returns>value * value </returns>
static public float Pow2(float value)
{
return value * value;
}
/// <summary>Normalize a rad angle to [0, 2*PI]</summary>
/// <param name="inputRad">Angle in radians</param>
/// <returns>Equivalent angle in radians in the interval [0, 2*PI]</returns>
static public float NormalizeAngleInRad(float inputRad)
{
float value = inputRad % (2 * Mathf.PI);
if (value < 0) { value += 2 * Mathf.PI; }
return value;
}
static public float Maximun(float num1, float num2)
{
if (num1 > num2) { return num1; }
else { return num2; }
}
/// <summary>
/// Returns true if the value to check has a finite value
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
static public bool IsFinite(float value)
{
return !float.IsNaN(value) && !float.IsInfinity(value);
}
static public bool IsFinite(Vector3 value)
{
return (!float.IsNaN(value.x) && !float.IsInfinity(value.x)) &&
(!float.IsNaN(value.y) && !float.IsInfinity(value.y)) &&
(!float.IsNaN(value.z) && !float.IsInfinity(value.z));
}
public static float Max(float x, float y)
{
// Or in-line it as x < y ? (y < z ? z : y) : (x < z ? z : x);
// Time it before micro-optimizing though!
return Mathf.Max(x, y);
}
public static float Max(float x, float y, float z)
{
// Or in-line it as x < y ? (y < z ? z : y) : (x < z ? z : x);
// Time it before micro-optimizing though!
return Mathf.Max(x, Mathf.Max(y, z));
}
public static float Max(Vector3 value)
{
// Or in-line it as x < y ? (y < z ? z : y) : (x < z ? z : x);
// Time it before micro-optimizing though!
return Mathf.Max(value.x, Mathf.Max(value.y, value.z));
}
/// <summary>
/// Returns true if x is in range [low..high], else false. Working for negative numbers also.
/// </summary>
/// <param name="low"></param>
/// <param name="high"></param>
/// <param name="x"></param>
/// <returns></returns>
public static bool InRange(int low, int high, int x)
{
return ((x - high) * (x - low) <= 0);
}
}
static class StringHom3r
{
/// <summary>Return string with the first char in uppercase and the rest in lowercase</summary>
/// <param name="str">string to ve converter</param>
/// <returns>string converter</returns>
static public string FirstLetterToUpper(string str)
{
str = str.ToLowerInvariant();
if (str == null)
return null;
if (str.Length > 1)
return char.ToUpper(str[0]) + str.Substring(1);
return str.ToUpper();
}
}
/// <summary>Hom3rModes_Type will try to show the mode in which HOM3R is working every moment</summary>
public enum THom3rPlatform { Editor, WebGL, Android, IOS, Windows, Other };
public enum THom3rMode { idle, capturing_surface_point, remove, local_explosion };
public enum THom3rExplosionMode { EXPLODE, IMPLODE };
public enum THom3rIsolationMode { idle, ISOLATE, WITH_REMOVEDNODES };
public enum THom3rSelectionMode { AREA, SPECIAL_NODE };
public enum THom3rLabelMode { idle, show, edit, add };
public enum THom3rPointCaptureMode { iddle, capturing, editing };
public enum THom3rCommandOrigin { ui, io};
public enum THom3rNavigationMode { regular, pan };
/// <summary> Class to store the state of the app in every moment.</summary>
public class CHom3rState
{
// Configuration from the interface
//public bool UIEnable { get; set; } // UI enable or not
//public bool automaticSelection { get; set; } // This controlled what happens when the user click over a object
//public bool touchInteractionEnable { get; set; } // This control if the touch interaction is On or not
//public bool mouseInteractionEnable { get; set; } // This control if the touch interaction is On or not
//Internal use
public bool generalState { get; set; } //Is false when any error happens
public bool productModelLoaded { get; set; } //Store if the model has been loaded or not
public bool _3DModelLoaded { get; set; } //Store if the model has been loaded or not
public THom3rPlatform platform { get; set; } //Store the environment if which Hom3r is working
public float smartTransparencyAlphaLevel { get; set; }
//Modes Management
public bool selectionBlocked { get; set; } //External blocking/unblocking of selection (indicate and confirm)
public bool captureSinglePointBlocked { get; set; } //External blocking/unblocking of SinglePoints capture
public bool navigationBlocked { get; set; } //External blocking/unblocking of Navigation (camera movements using the mouse)
public bool isolateModeActive { get; set; } //Store if the isolate mode is activate or not
public bool smartTransparencyModeActive { get; set; } //Store if the isolate mode is activate or not
public bool singlePointLocationModeActive { get; set; } //Store if the node
// Store the current mode where HOM3R is working
private THom3rMode current_mode;
public THom3rMode currentMode {
get { return current_mode; }
set {
current_mode = value;
hom3r.coreLink.EmitEvent(new CCoreEvent(TCoreEvent.Core_ModeChanged));
}
}
public THom3rExplosionMode currentExplosionMode { get; set; } //Store the current explosion mode where HOM3R is working
public THom3rSelectionMode currentSelectionMode { get; set; } //Store the current mode of selection
public THom3rIsolationMode currentIsolateMode { get; set; } //Store the current visualization mode (if there are removed nodes ot not)
public THom3rLabelMode currentLabelMode { get; set; } //Store the current labeling mode
public THom3rPointCaptureMode currentPointCaptureMode { get; set; }
public THom3rNavigationMode navigationMode; // Which navigation system are we using
//Layers
public string labelsUILayer; // Store camera layer for Labels
public string productRootLayer; // Store camera layer for 3D model
}
public class CQuickLinks
{
public GameObject navigationSystemObject; // Pointer to the main camera object
public GameObject uiObject; // Pointer to the UI object
public GameObject scriptsObject; // Pointer to the scripts container object
//public GameObject configurationObject; // Pointer to the configuration script container object
public GameObject _3DModelRoot; // Pointer to the main product object
public GameObject labelsObject; // Pointer to the label container object
public GameObject manipulatorObject; //Pointer to the ARCore manipulator Object
}
public static class hom3r {
static public Core coreLink;
static public CQuickLinks quickLinks = new CQuickLinks();
static public CHom3rState state; // Current state of the app
}