GizmoRender.cs 35 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148
  1. using System;
  2. using UnityEngine;
  3. public class GizmoRender : MonoBehaviour
  4. {
  5. public static bool control_lock
  6. {
  7. get
  8. {
  9. return GizmoRender.local_control_lock_ || GizmoRender.global_control_lock;
  10. }
  11. }
  12. public void Awake()
  13. {
  14. if (!this.lineMaterial)
  15. {
  16. Shader shader = Shader.Find("Hidden/Internal-Colored");
  17. this.lineMaterial = new Material(shader);
  18. this.lineMaterial.hideFlags = HideFlags.HideAndDontSave;
  19. this.lineMaterial.SetInt("_ZTest", 0);
  20. this.lineMaterial.SetInt("_SrcBlend", 5);
  21. this.lineMaterial.SetInt("_DstBlend", 10);
  22. this.lineMaterial.SetInt("_Cull", 0);
  23. this.lineMaterial.SetInt("_ZWrite", 0);
  24. }
  25. this.untransRight = new Vector3(1f, 0f, 0f);
  26. this.untransUp = new Vector3(0f, 1f, 0f);
  27. this.untransForward = new Vector3(0f, 0f, 1f);
  28. this.Dir = Vector3.zero;
  29. this.colorRed = new Color(1f, 0f, 0f, 1f);
  30. this.colorGreen = new Color(0f, 1f, 0f, 1f);
  31. this.colorBlue = new Color(0f, 0f, 1f, 1f);
  32. this.colorFan = new Color(1f, 1f, 0f, 0.5f);
  33. this.colorWhite = new Color(1f, 1f, 1f, 0.3f);
  34. this.colorWire = new Color(1f, 1f, 1f, 0.05f);
  35. this.colorLine = new Color(1f, 1f, 0f, 0.8f);
  36. this.selX = this.colorRed;
  37. this.selY = this.colorGreen;
  38. this.selZ = this.colorBlue;
  39. this.panY = this.colorGreen;
  40. this.panX = this.colorRed;
  41. this.panZ = this.colorBlue;
  42. this.circleX = this.colorRed;
  43. this.circleY = this.colorGreen;
  44. this.circleZ = this.colorBlue;
  45. this.beSelectedType = GizmoRender.MOVETYPE.NONE;
  46. this.hitMouseDown = (this.hitMouseMove = Vector3.zero);
  47. this.moveLockVertex = false;
  48. this.matScal = new Vector3(1f, 1f, 1f);
  49. this.rotationMatrix = Matrix4x4.TRS(base.transform.position, base.transform.rotation, this.matScal);
  50. this.locklocalToWorldMatrix = this.rotationMatrix;
  51. this.eRotate = true;
  52. this.oScal = base.transform.localScale;
  53. }
  54. public virtual void Update()
  55. {
  56. if (GameMain.Instance.VRMode)
  57. {
  58. return;
  59. }
  60. if (NInput.GetMouseButtonDown(0))
  61. {
  62. if (!GizmoRender.ray_check_)
  63. {
  64. Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
  65. Physics.Raycast(ray, out GizmoRender.ray_hit_);
  66. GizmoRender.ui_ray_check_ = UICamera.Raycast(Input.mousePosition);
  67. GizmoRender.ray_check_ = true;
  68. GizmoRender.is_drag_ = ((GizmoRender.ray_hit_.transform == null || GizmoRender.ray_hit_.transform.gameObject.layer != 8) && !GizmoRender.ui_ray_check_);
  69. }
  70. }
  71. else if (!NInput.GetMouseButton(0))
  72. {
  73. GizmoRender.ray_check_ = false;
  74. GizmoRender.is_drag_ = false;
  75. }
  76. }
  77. public virtual void OnDragEnd()
  78. {
  79. }
  80. public virtual void OnRenderObject()
  81. {
  82. if (GameMain.Instance.VRMode)
  83. {
  84. return;
  85. }
  86. if (!this.Visible)
  87. {
  88. if (this.beSelectedType != GizmoRender.MOVETYPE.NONE && GizmoRender.local_control_lock_)
  89. {
  90. GizmoRender.local_control_lock_ = false;
  91. }
  92. this.beSelectedType = GizmoRender.MOVETYPE.NONE;
  93. return;
  94. }
  95. GizmoRender.MOVETYPE movetype = this.beSelectedType;
  96. if (this.beSelectedType == GizmoRender.MOVETYPE.NONE)
  97. {
  98. this.panY = this.colorGreen;
  99. this.panX = this.colorRed;
  100. this.panZ = this.colorBlue;
  101. this.selX = this.colorRed;
  102. this.selY = this.colorGreen;
  103. this.selZ = this.colorBlue;
  104. this.circleX = this.colorRed;
  105. this.circleY = this.colorGreen;
  106. this.circleZ = this.colorBlue;
  107. this.moveLockVertex = false;
  108. this.oScal = base.transform.localScale;
  109. }
  110. if (!NInput.GetMouseButton(0) || !GizmoRender.is_drag_)
  111. {
  112. if (this.beSelectedType != GizmoRender.MOVETYPE.NONE && GizmoRender.local_control_lock_)
  113. {
  114. GizmoRender.local_control_lock_ = false;
  115. this.OnDragEnd();
  116. }
  117. this.beSelectedType = GizmoRender.MOVETYPE.NONE;
  118. }
  119. else
  120. {
  121. this.planeXZ.SetNormalAndPosition(base.transform.up, base.transform.position);
  122. this.planeXY.SetNormalAndPosition(base.transform.forward, base.transform.position);
  123. this.planeYZ.SetNormalAndPosition(base.transform.right, base.transform.position);
  124. Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
  125. float distance = 0f;
  126. this.planeXZ.Raycast(ray, out distance);
  127. Vector3 vector = ray.GetPoint(distance);
  128. if (this.beSelectedType == GizmoRender.MOVETYPE.RY)
  129. {
  130. vector = this.locklocalToWorldMatrix.inverse.MultiplyPoint(vector);
  131. }
  132. else
  133. {
  134. vector = this.rotationMatrix.inverse.MultiplyPoint(vector);
  135. }
  136. if (this.eAxis)
  137. {
  138. if (!GizmoRender.control_lock && this.beSelectedType == GizmoRender.MOVETYPE.NONE && vector.x > 0f && vector.x <= 0.3f * this.generalLens && vector.z > 0f && vector.z <= 0.3f * this.generalLens)
  139. {
  140. this.panY = this.colorFan;
  141. this.beSelectedType = GizmoRender.MOVETYPE.XZ;
  142. this.moveLockVertex = true;
  143. this.hitMouseDown = vector;
  144. }
  145. if (this.beSelectedType == GizmoRender.MOVETYPE.XZ && (NInput.GetAxis("Mouse X") != 0f || NInput.GetAxis("Mouse Y") != 0f))
  146. {
  147. this.hitMouseMove = vector - this.hitMouseDown;
  148. this.hitMouseMove.y = 0f;
  149. base.transform.position += base.transform.rotation * this.hitMouseMove;
  150. }
  151. if (this.beSelectedType == GizmoRender.MOVETYPE.NONE && vector.x > 0f && vector.x <= this.generalLens && Mathf.Abs(vector.z) < this.lineSelectedThick * this.generalLens)
  152. {
  153. this.selX = this.colorFan;
  154. this.beSelectedType = GizmoRender.MOVETYPE.X;
  155. this.hitMouseDown = vector;
  156. }
  157. if (this.beSelectedType == GizmoRender.MOVETYPE.X && (NInput.GetAxis("Mouse X") != 0f || NInput.GetAxis("Mouse Y") != 0f))
  158. {
  159. this.hitMouseMove = vector - this.hitMouseDown;
  160. this.hitMouseMove.y = 0f;
  161. this.hitMouseMove.z = 0f;
  162. base.transform.position += base.transform.rotation * this.hitMouseMove;
  163. }
  164. if (this.beSelectedType == GizmoRender.MOVETYPE.NONE && vector.z > 0f && vector.z <= this.generalLens && Mathf.Abs(vector.x) < this.lineSelectedThick * this.generalLens)
  165. {
  166. this.selZ = this.colorFan;
  167. this.beSelectedType = GizmoRender.MOVETYPE.Z;
  168. this.hitMouseDown = vector;
  169. }
  170. if (this.beSelectedType == GizmoRender.MOVETYPE.Z && (NInput.GetAxis("Mouse X") != 0f || NInput.GetAxis("Mouse Y") != 0f))
  171. {
  172. this.hitMouseMove = vector - this.hitMouseDown;
  173. this.hitMouseMove.y = 0f;
  174. this.hitMouseMove.x = 0f;
  175. base.transform.position += base.transform.rotation * this.hitMouseMove;
  176. }
  177. }
  178. if (this.eScal)
  179. {
  180. if (!GizmoRender.control_lock && this.beSelectedType == GizmoRender.MOVETYPE.NONE && vector.x > 0f && vector.x <= 0.3f * this.generalLens && vector.z > 0f && vector.z <= 0.3f * this.generalLens && vector.x + vector.z - 0.3f * this.generalLens <= 0f)
  181. {
  182. this.panY = this.colorFan;
  183. this.beSelectedType = GizmoRender.MOVETYPE.TXZ;
  184. this.moveLockVertex = true;
  185. this.hitMouseDown = vector;
  186. }
  187. if (this.beSelectedType == GizmoRender.MOVETYPE.TXZ && (NInput.GetAxis("Mouse X") != 0f || NInput.GetAxis("Mouse Y") != 0f))
  188. {
  189. this.hitMouseMove = vector - this.hitMouseDown;
  190. this.hitMouseMove.y = 0f;
  191. float num = this.hitMouseMove.x + this.hitMouseMove.z;
  192. float num2 = (float)((int)(num * 10f)) / 10f;
  193. base.transform.localScale = this.oScal + new Vector3(num2, 0f, num2);
  194. }
  195. if (this.beSelectedType == GizmoRender.MOVETYPE.NONE && vector.x > 0f && vector.x <= this.generalLens && Mathf.Abs(vector.z) < this.lineSelectedThick * this.generalLens)
  196. {
  197. this.selX = this.colorFan;
  198. this.beSelectedType = GizmoRender.MOVETYPE.TX;
  199. this.hitMouseDown = vector;
  200. }
  201. if (this.beSelectedType == GizmoRender.MOVETYPE.TX && (NInput.GetAxis("Mouse X") != 0f || NInput.GetAxis("Mouse Y") != 0f))
  202. {
  203. this.hitMouseMove = vector - this.hitMouseDown;
  204. this.hitMouseMove.y = 0f;
  205. this.hitMouseMove.z = 0f;
  206. float x = this.hitMouseMove.x;
  207. float x2 = (float)((int)(x * 10f)) / 10f;
  208. base.transform.localScale = this.oScal + new Vector3(x2, 0f, 0f);
  209. }
  210. if (this.beSelectedType == GizmoRender.MOVETYPE.NONE && vector.z > 0f && vector.z <= this.generalLens && Mathf.Abs(vector.x) < this.lineSelectedThick * this.generalLens)
  211. {
  212. this.selZ = this.colorFan;
  213. this.beSelectedType = GizmoRender.MOVETYPE.TZ;
  214. this.hitMouseDown = vector;
  215. }
  216. if (this.beSelectedType == GizmoRender.MOVETYPE.TZ && (NInput.GetAxis("Mouse X") != 0f || NInput.GetAxis("Mouse Y") != 0f))
  217. {
  218. this.hitMouseMove = vector - this.hitMouseDown;
  219. this.hitMouseMove.y = 0f;
  220. this.hitMouseMove.x = 0f;
  221. float z = this.hitMouseMove.z;
  222. float z2 = (float)((int)(z * 10f)) / 10f;
  223. base.transform.localScale = this.oScal + new Vector3(0f, 0f, z2);
  224. }
  225. }
  226. float num3 = Mathf.Sqrt(vector.x * vector.x + vector.z * vector.z);
  227. if (this.eRotate)
  228. {
  229. if (Vector3.Dot(vector, this.uForward) >= 0f && !GizmoRender.control_lock && this.VisibleRotateY && this.beSelectedType == GizmoRender.MOVETYPE.NONE && num3 > (1f - this.lineRSelectedThick) * this.generalLens && num3 < (1f + this.lineRSelectedThick) * this.generalLens)
  230. {
  231. this.circleY = this.colorFan;
  232. this.beSelectedType = GizmoRender.MOVETYPE.RY;
  233. this.moveLockVertex = true;
  234. this.hitMouseDown = vector;
  235. this.locklocalToWorldMatrix = this.rotationMatrix;
  236. this.rotaCal = 0f;
  237. }
  238. if (this.beSelectedType == GizmoRender.MOVETYPE.RY)
  239. {
  240. this.hitMouseMove = vector;
  241. float num4 = Vector3.Dot(this.hitMouseDown.normalized, this.untransRight);
  242. float num5 = Vector3.Dot(this.hitMouseMove.normalized, this.untransRight);
  243. float num6 = Vector3.Dot(this.hitMouseDown.normalized, this.hitMouseMove.normalized);
  244. num4 = this.SnapDot(num4, this.hitMouseDown.x, this.hitMouseDown.z);
  245. num5 = this.SnapDot(num5, this.hitMouseMove.x, this.hitMouseMove.z);
  246. num6 = Mathf.Acos(num6);
  247. if (num4 == num5)
  248. {
  249. goto IL_1C9F;
  250. }
  251. float num7 = num4 + 3.14159274f;
  252. if (num7 > 6.28318548f)
  253. {
  254. if ((num5 < 0f || num5 > num7 - 6.28318548f) && num5 <= num4)
  255. {
  256. num6 = -num6;
  257. }
  258. }
  259. else if (num5 < num4 || num5 > num7)
  260. {
  261. num6 = -num6;
  262. }
  263. if (float.IsNaN(num6))
  264. {
  265. goto IL_1C9F;
  266. }
  267. this.rotaCal = num6 - this.rotaCal;
  268. this.DrawCam(this.colorWhite, num4, num6, GizmoRender.MOVETYPE.Y);
  269. base.transform.RotateAround(base.transform.up, -this.rotaCal);
  270. this.rotaCal = num6;
  271. }
  272. }
  273. distance = 0f;
  274. this.planeXY.Raycast(ray, out distance);
  275. vector = ray.GetPoint(distance);
  276. if (this.beSelectedType == GizmoRender.MOVETYPE.RZ)
  277. {
  278. vector = this.locklocalToWorldMatrix.inverse.MultiplyPoint(vector);
  279. }
  280. else
  281. {
  282. vector = this.rotationMatrix.inverse.MultiplyPoint(vector);
  283. }
  284. if (this.eAxis)
  285. {
  286. if (!GizmoRender.control_lock && this.beSelectedType == GizmoRender.MOVETYPE.NONE && vector.x > 0f && vector.x <= 0.3f * this.generalLens && vector.y > 0f && vector.y <= 0.3f * this.generalLens)
  287. {
  288. this.panZ = this.colorFan;
  289. this.beSelectedType = GizmoRender.MOVETYPE.XY;
  290. this.hitMouseDown = vector;
  291. }
  292. if (this.beSelectedType == GizmoRender.MOVETYPE.XY)
  293. {
  294. this.hitMouseMove = vector - this.hitMouseDown;
  295. this.hitMouseMove.z = 0f;
  296. base.transform.position += base.transform.rotation * this.hitMouseMove;
  297. }
  298. if (this.beSelectedType == GizmoRender.MOVETYPE.NONE && vector.x > 0f && vector.x <= this.generalLens && Mathf.Abs(vector.y) < this.lineSelectedThick * this.generalLens)
  299. {
  300. this.selX = this.colorFan;
  301. this.beSelectedType = GizmoRender.MOVETYPE.X2;
  302. this.hitMouseDown = vector;
  303. }
  304. if (this.beSelectedType == GizmoRender.MOVETYPE.X2 && (NInput.GetAxis("Mouse X") != 0f || NInput.GetAxis("Mouse Y") != 0f))
  305. {
  306. this.hitMouseMove = vector - this.hitMouseDown;
  307. this.hitMouseMove.y = 0f;
  308. this.hitMouseMove.z = 0f;
  309. base.transform.position += base.transform.rotation * this.hitMouseMove;
  310. }
  311. if (this.beSelectedType == GizmoRender.MOVETYPE.NONE && vector.y > 0f && vector.y <= this.generalLens && Mathf.Abs(vector.x) < this.lineSelectedThick * this.generalLens)
  312. {
  313. this.selY = this.colorFan;
  314. this.beSelectedType = GizmoRender.MOVETYPE.Y;
  315. this.hitMouseDown = vector;
  316. }
  317. if (this.beSelectedType == GizmoRender.MOVETYPE.Y && (NInput.GetAxis("Mouse X") != 0f || NInput.GetAxis("Mouse Y") != 0f))
  318. {
  319. this.hitMouseMove = vector - this.hitMouseDown;
  320. this.hitMouseMove.z = 0f;
  321. this.hitMouseMove.x = 0f;
  322. base.transform.position += base.transform.rotation * this.hitMouseMove;
  323. }
  324. }
  325. if (this.eScal)
  326. {
  327. if (!GizmoRender.control_lock && this.beSelectedType == GizmoRender.MOVETYPE.NONE && vector.x > 0f && vector.x <= 0.3f * this.generalLens && vector.y > 0f && vector.y <= 0.3f * this.generalLens && vector.x + vector.y - 0.3f * this.generalLens <= 0f)
  328. {
  329. this.panZ = this.colorFan;
  330. this.beSelectedType = GizmoRender.MOVETYPE.TXY;
  331. this.hitMouseDown = vector;
  332. }
  333. if (this.beSelectedType == GizmoRender.MOVETYPE.TXY)
  334. {
  335. this.hitMouseMove = vector - this.hitMouseDown;
  336. this.hitMouseMove.z = 0f;
  337. float num8 = this.hitMouseMove.x + this.hitMouseMove.y;
  338. float num9 = (float)((int)(num8 * 10f)) / 10f;
  339. base.transform.localScale = this.oScal + new Vector3(num9, num9, 0f);
  340. }
  341. if (this.beSelectedType == GizmoRender.MOVETYPE.NONE && vector.x > 0f && vector.x <= this.generalLens && Mathf.Abs(vector.y) < this.lineSelectedThick * this.generalLens)
  342. {
  343. this.selX = this.colorFan;
  344. this.beSelectedType = GizmoRender.MOVETYPE.TX2;
  345. this.moveLockVertex = true;
  346. this.hitMouseDown = vector;
  347. }
  348. if (this.beSelectedType == GizmoRender.MOVETYPE.TX2 && (NInput.GetAxis("Mouse X") != 0f || NInput.GetAxis("Mouse Y") != 0f))
  349. {
  350. this.hitMouseMove = vector - this.hitMouseDown;
  351. this.hitMouseMove.y = 0f;
  352. this.hitMouseMove.z = 0f;
  353. float x3 = this.hitMouseMove.x;
  354. float x4 = (float)((int)(x3 * 10f)) / 10f;
  355. base.transform.localScale = this.oScal + new Vector3(x4, 0f, 0f);
  356. }
  357. if (this.beSelectedType == GizmoRender.MOVETYPE.NONE && vector.y > 0f && vector.y <= this.generalLens && Mathf.Abs(vector.x) < this.lineSelectedThick * this.generalLens)
  358. {
  359. this.selY = this.colorFan;
  360. this.beSelectedType = GizmoRender.MOVETYPE.TY;
  361. this.hitMouseDown = vector;
  362. }
  363. if (this.beSelectedType == GizmoRender.MOVETYPE.TY && (NInput.GetAxis("Mouse X") != 0f || NInput.GetAxis("Mouse Y") != 0f))
  364. {
  365. this.hitMouseMove = vector - this.hitMouseDown;
  366. this.hitMouseMove.z = 0f;
  367. this.hitMouseMove.x = 0f;
  368. float y = this.hitMouseMove.y;
  369. float y2 = (float)((int)(y * 10f)) / 10f;
  370. base.transform.localScale = this.oScal + new Vector3(0f, y2, 0f);
  371. }
  372. }
  373. num3 = Mathf.Sqrt(vector.x * vector.x + vector.y * vector.y);
  374. if (this.eRotate)
  375. {
  376. if (Vector3.Dot(vector, this.fForward) >= 0f && !GizmoRender.control_lock && this.VisibleRotateZ && this.beSelectedType == GizmoRender.MOVETYPE.NONE && num3 > (1f - this.lineRSelectedThick) * this.generalLens && num3 < (1f + this.lineRSelectedThick) * this.generalLens)
  377. {
  378. this.circleZ = this.colorFan;
  379. this.beSelectedType = GizmoRender.MOVETYPE.RZ;
  380. this.moveLockVertex = true;
  381. this.hitMouseDown = vector;
  382. this.locklocalToWorldMatrix = this.rotationMatrix;
  383. this.rotaCal = 0f;
  384. }
  385. if (this.beSelectedType == GizmoRender.MOVETYPE.RZ)
  386. {
  387. this.hitMouseMove = vector;
  388. float num10 = Vector3.Dot(this.hitMouseDown.normalized, this.untransUp);
  389. float num11 = Vector3.Dot(this.hitMouseMove.normalized, this.untransUp);
  390. float num12 = Vector3.Dot(this.hitMouseDown.normalized, this.hitMouseMove.normalized);
  391. num10 = this.SnapDot(num10, this.hitMouseDown.y, this.hitMouseDown.x);
  392. num11 = this.SnapDot(num11, this.hitMouseMove.y, this.hitMouseMove.x);
  393. num12 = Mathf.Acos(num12);
  394. if (num10 == num11)
  395. {
  396. goto IL_1C9F;
  397. }
  398. float num13 = num10 + 3.14159274f;
  399. if (num13 > 6.28318548f)
  400. {
  401. if ((num11 < 0f || num11 > num13 - 6.28318548f) && num11 <= num10)
  402. {
  403. num12 = -num12;
  404. }
  405. }
  406. else if (num11 < num10 || num11 > num13)
  407. {
  408. num12 = -num12;
  409. }
  410. if (float.IsNaN(num12))
  411. {
  412. goto IL_1C9F;
  413. }
  414. this.rotaCal = num12 - this.rotaCal;
  415. this.DrawCam(this.colorWhite, num10, num12, GizmoRender.MOVETYPE.Z);
  416. base.transform.RotateAround(base.transform.forward, -this.rotaCal);
  417. this.rotaCal = num12;
  418. }
  419. }
  420. distance = 0f;
  421. this.planeYZ.Raycast(ray, out distance);
  422. vector = ray.GetPoint(distance);
  423. if (this.beSelectedType == GizmoRender.MOVETYPE.RX)
  424. {
  425. vector = this.locklocalToWorldMatrix.inverse.MultiplyPoint(vector);
  426. }
  427. else
  428. {
  429. vector = this.rotationMatrix.inverse.MultiplyPoint(vector);
  430. }
  431. if (this.eAxis)
  432. {
  433. if (!GizmoRender.control_lock && this.beSelectedType == GizmoRender.MOVETYPE.NONE && vector.z > 0f && vector.z <= 0.3f * this.generalLens && vector.y > 0f && vector.y <= 0.3f * this.generalLens)
  434. {
  435. this.panX = this.colorFan;
  436. this.beSelectedType = GizmoRender.MOVETYPE.YZ;
  437. this.hitMouseDown = vector;
  438. }
  439. if (this.beSelectedType == GizmoRender.MOVETYPE.YZ)
  440. {
  441. this.hitMouseMove = vector - this.hitMouseDown;
  442. this.hitMouseMove.x = 0f;
  443. base.transform.position += base.transform.rotation * this.hitMouseMove;
  444. }
  445. if (this.beSelectedType == GizmoRender.MOVETYPE.NONE && vector.z > 0f && vector.z <= this.generalLens && Mathf.Abs(vector.y) < this.lineSelectedThick * this.generalLens)
  446. {
  447. this.selZ = this.colorFan;
  448. this.beSelectedType = GizmoRender.MOVETYPE.Z2;
  449. this.hitMouseDown = vector;
  450. }
  451. if (this.beSelectedType == GizmoRender.MOVETYPE.Z2 && (NInput.GetAxis("Mouse X") != 0f || NInput.GetAxis("Mouse Y") != 0f))
  452. {
  453. this.hitMouseMove = vector - this.hitMouseDown;
  454. this.hitMouseMove.y = 0f;
  455. this.hitMouseMove.x = 0f;
  456. base.transform.position += base.transform.rotation * this.hitMouseMove;
  457. }
  458. if (this.beSelectedType == GizmoRender.MOVETYPE.NONE && vector.y > 0f && vector.y <= this.generalLens && Mathf.Abs(vector.z) < this.lineSelectedThick * this.generalLens)
  459. {
  460. this.selY = this.colorFan;
  461. this.beSelectedType = GizmoRender.MOVETYPE.Y2;
  462. this.hitMouseDown = vector;
  463. }
  464. if (this.beSelectedType == GizmoRender.MOVETYPE.Y2 && (NInput.GetAxis("Mouse X") != 0f || NInput.GetAxis("Mouse Y") != 0f))
  465. {
  466. this.hitMouseMove = vector - this.hitMouseDown;
  467. this.hitMouseMove.z = 0f;
  468. this.hitMouseMove.x = 0f;
  469. base.transform.position += base.transform.rotation * this.hitMouseMove;
  470. }
  471. }
  472. if (this.eScal)
  473. {
  474. if (!GizmoRender.control_lock && this.beSelectedType == GizmoRender.MOVETYPE.NONE && vector.z > 0f && vector.z <= 0.3f * this.generalLens && vector.y > 0f && vector.y <= 0.3f * this.generalLens && vector.y + vector.z - 0.3f * this.generalLens <= 0f)
  475. {
  476. this.panX = this.colorFan;
  477. this.beSelectedType = GizmoRender.MOVETYPE.TYZ;
  478. this.hitMouseDown = vector;
  479. }
  480. if (this.beSelectedType == GizmoRender.MOVETYPE.TYZ)
  481. {
  482. this.hitMouseMove = vector - this.hitMouseDown;
  483. this.hitMouseMove.x = 0f;
  484. float num14 = this.hitMouseMove.z + this.hitMouseMove.y;
  485. float num15 = (float)((int)(num14 * 10f)) / 10f;
  486. base.transform.localScale = this.oScal + new Vector3(0f, num15, num15);
  487. }
  488. if (this.beSelectedType == GizmoRender.MOVETYPE.NONE && vector.z > 0f && vector.z <= this.generalLens && Mathf.Abs(vector.y) < this.lineSelectedThick * this.generalLens)
  489. {
  490. this.selZ = this.colorFan;
  491. this.beSelectedType = GizmoRender.MOVETYPE.TZ2;
  492. this.hitMouseDown = vector;
  493. }
  494. if (this.beSelectedType == GizmoRender.MOVETYPE.TZ2 && (NInput.GetAxis("Mouse X") != 0f || NInput.GetAxis("Mouse Y") != 0f))
  495. {
  496. this.hitMouseMove = vector - this.hitMouseDown;
  497. this.hitMouseMove.y = 0f;
  498. this.hitMouseMove.x = 0f;
  499. float z3 = this.hitMouseMove.z;
  500. float z4 = (float)((int)(z3 * 10f)) / 10f;
  501. base.transform.localScale = this.oScal + new Vector3(0f, 0f, z4);
  502. }
  503. if (this.beSelectedType == GizmoRender.MOVETYPE.NONE && vector.y > 0f && vector.y <= this.generalLens && Mathf.Abs(vector.z) < this.lineSelectedThick * this.generalLens)
  504. {
  505. this.selY = this.colorFan;
  506. this.beSelectedType = GizmoRender.MOVETYPE.TY2;
  507. this.hitMouseDown = vector;
  508. }
  509. if (this.beSelectedType == GizmoRender.MOVETYPE.TY2 && (NInput.GetAxis("Mouse X") != 0f || NInput.GetAxis("Mouse Y") != 0f))
  510. {
  511. this.hitMouseMove = vector - this.hitMouseDown;
  512. this.hitMouseMove.z = 0f;
  513. this.hitMouseMove.x = 0f;
  514. float y3 = this.hitMouseMove.y;
  515. float y4 = (float)((int)(y3 * 10f)) / 10f;
  516. base.transform.localScale = this.oScal + new Vector3(0f, y4, 0f);
  517. }
  518. }
  519. num3 = Mathf.Sqrt(vector.z * vector.z + vector.y * vector.y);
  520. if (this.eRotate)
  521. {
  522. if (Vector3.Dot(vector, this.rForward) >= 0f && !GizmoRender.control_lock && this.VisibleRotateX && this.beSelectedType == GizmoRender.MOVETYPE.NONE && num3 > (1f - this.lineRSelectedThick) * this.generalLens && num3 < (1f + this.lineRSelectedThick) * this.generalLens)
  523. {
  524. this.circleX = this.colorFan;
  525. this.beSelectedType = GizmoRender.MOVETYPE.RX;
  526. this.moveLockVertex = true;
  527. this.hitMouseDown = vector;
  528. this.locklocalToWorldMatrix = this.rotationMatrix;
  529. this.rotaCal = 0f;
  530. }
  531. if (this.beSelectedType == GizmoRender.MOVETYPE.RX)
  532. {
  533. this.hitMouseMove = vector;
  534. float num16 = Vector3.Dot(this.hitMouseDown.normalized, this.untransForward);
  535. float num17 = Vector3.Dot(this.hitMouseMove.normalized, this.untransForward);
  536. float num18 = Vector3.Dot(this.hitMouseDown.normalized, this.hitMouseMove.normalized);
  537. num16 = this.SnapDot(num16, this.hitMouseDown.z, this.hitMouseDown.y);
  538. num17 = this.SnapDot(num17, this.hitMouseMove.z, this.hitMouseMove.y);
  539. num18 = Mathf.Acos(num18);
  540. if (num16 != num17)
  541. {
  542. float num19 = num16 + 3.14159274f;
  543. if (num19 > 6.28318548f)
  544. {
  545. if ((num17 < 0f || num17 > num19 - 6.28318548f) && num17 <= num16)
  546. {
  547. num18 = -num18;
  548. }
  549. }
  550. else if (num17 < num16 || num17 > num19)
  551. {
  552. num18 = -num18;
  553. }
  554. if (!float.IsNaN(num18))
  555. {
  556. this.rotaCal = num18 - this.rotaCal;
  557. this.DrawCam(this.colorWhite, num16, num18, GizmoRender.MOVETYPE.X);
  558. base.transform.RotateAround(base.transform.right, -this.rotaCal);
  559. this.rotaCal = num18;
  560. }
  561. }
  562. }
  563. }
  564. }
  565. IL_1C9F:
  566. if (movetype == GizmoRender.MOVETYPE.NONE && this.beSelectedType != GizmoRender.MOVETYPE.NONE && !GizmoRender.local_control_lock_)
  567. {
  568. GizmoRender.local_control_lock_ = true;
  569. }
  570. this.RenderGizmos();
  571. }
  572. public void RenderGizmos()
  573. {
  574. this.Dir = Camera.main.transform.position - base.transform.position;
  575. float magnitude = this.Dir.magnitude;
  576. this.generalLens = -2f * Mathf.Tan(0.5f * Camera.main.fieldOfView) * magnitude / 50f;
  577. this.generalLens *= this.offsetScale;
  578. this.Dir.Normalize();
  579. GL.PushMatrix();
  580. this.rotationMatrix = base.transform.localToWorldMatrix;
  581. this.rotationMatrix = Matrix4x4.TRS(base.transform.position, base.transform.rotation, this.matScal);
  582. GL.MultMatrix(this.rotationMatrix);
  583. this.lineMaterial.SetPass(0);
  584. if (this.eRotate)
  585. {
  586. Vector3 rhs = base.transform.InverseTransformPoint(Camera.main.transform.position);
  587. Vector3 vector = Vector3.Cross(this.untransRight, rhs);
  588. vector.Normalize();
  589. vector *= this.generalLens;
  590. Vector3 vector2 = Vector3.Cross(vector, this.untransRight);
  591. vector2.Normalize();
  592. vector2 *= this.generalLens;
  593. if (this.VisibleRotateX && GizmoRender.UIVisible)
  594. {
  595. this.DrawCircleHalf(this.circleX, vector, vector2);
  596. }
  597. this.rForward = vector2;
  598. vector = Vector3.Cross(this.untransUp, rhs);
  599. vector.Normalize();
  600. vector *= this.generalLens;
  601. vector2 = Vector3.Cross(vector, this.untransUp);
  602. vector2.Normalize();
  603. vector2 *= this.generalLens;
  604. if (this.VisibleRotateY && GizmoRender.UIVisible)
  605. {
  606. this.DrawCircleHalf(this.circleY, vector, vector2);
  607. }
  608. this.uForward = vector2;
  609. vector = Vector3.Cross(this.untransForward, rhs);
  610. vector.Normalize();
  611. vector *= this.generalLens;
  612. vector2 = Vector3.Cross(vector, this.untransForward);
  613. vector2.Normalize();
  614. vector2 *= this.generalLens;
  615. if (this.VisibleRotateZ && GizmoRender.UIVisible)
  616. {
  617. this.DrawCircleHalf(this.circleZ, vector, vector2);
  618. }
  619. this.fForward = vector2;
  620. }
  621. if (this.eAxis)
  622. {
  623. this.DrawAxis(this.untransRight * this.generalLens, this.untransUp, this.untransForward, 0.04f * this.generalLens, 0.9f, this.selX);
  624. this.DrawAxis(this.untransUp * this.generalLens, this.untransRight, this.untransForward, 0.04f * this.generalLens, 0.9f, this.selY);
  625. this.DrawAxis(this.untransForward * this.generalLens, this.untransRight, this.untransUp, 0.04f * this.generalLens, 0.9f, this.selZ);
  626. this.DrawQuad(0.3f * this.generalLens, false, this.untransForward, this.untransUp, this.panX);
  627. this.DrawQuad(0.3f * this.generalLens, false, this.untransRight, this.untransForward, this.panY);
  628. this.DrawQuad(0.3f * this.generalLens, false, this.untransRight, this.untransUp, this.panZ);
  629. }
  630. if (this.eScal)
  631. {
  632. this.DrawAxis(this.untransRight * this.generalLens, this.untransUp, this.untransForward, 0.04f * this.generalLens, 0.9f, this.selX);
  633. this.DrawAxis(this.untransUp * this.generalLens, this.untransRight, this.untransForward, 0.04f * this.generalLens, 0.9f, this.selY);
  634. this.DrawAxis(this.untransForward * this.generalLens, this.untransRight, this.untransUp, 0.04f * this.generalLens, 0.9f, this.selZ);
  635. this.DrawTri(0.3f * this.generalLens, false, this.untransForward, this.untransUp, this.panX);
  636. this.DrawTri(0.3f * this.generalLens, false, this.untransRight, this.untransForward, this.panY);
  637. this.DrawTri(0.3f * this.generalLens, false, this.untransRight, this.untransUp, this.panZ);
  638. }
  639. GL.PopMatrix();
  640. }
  641. private void DrawCam(Color col, float sang, float eng, GizmoRender.MOVETYPE dtype)
  642. {
  643. GL.PushMatrix();
  644. this.rotationMatrix = this.locklocalToWorldMatrix;
  645. GL.MultMatrix(this.rotationMatrix);
  646. this.lineMaterial.SetPass(0);
  647. GL.Begin(4);
  648. GL.Color(col);
  649. if (dtype != GizmoRender.MOVETYPE.X)
  650. {
  651. if (dtype != GizmoRender.MOVETYPE.Y)
  652. {
  653. if (dtype == GizmoRender.MOVETYPE.Z)
  654. {
  655. for (int i = 0; i < 20; i++)
  656. {
  657. float f = sang + eng * (float)i / 20f;
  658. GL.Vertex3(0f, 0f, 0f);
  659. GL.Vertex3(Mathf.Sin(f) * this.generalLens, Mathf.Cos(f) * this.generalLens, 0f);
  660. f = sang + eng * (float)(i + 1) / 20f;
  661. GL.Vertex3(Mathf.Sin(f) * this.generalLens, Mathf.Cos(f) * this.generalLens, 0f);
  662. }
  663. }
  664. }
  665. else
  666. {
  667. for (int j = 0; j < 20; j++)
  668. {
  669. float f = sang + eng * (float)j / 20f;
  670. GL.Vertex3(0f, 0f, 0f);
  671. GL.Vertex3(Mathf.Cos(f) * this.generalLens, 0f, Mathf.Sin(f) * this.generalLens);
  672. f = sang + eng * (float)(j + 1) / 20f;
  673. GL.Vertex3(Mathf.Cos(f) * this.generalLens, 0f, Mathf.Sin(f) * this.generalLens);
  674. }
  675. }
  676. }
  677. else
  678. {
  679. for (int k = 0; k < 20; k++)
  680. {
  681. float f = sang + eng * (float)k / 20f;
  682. GL.Vertex3(0f, 0f, 0f);
  683. GL.Vertex3(0f, Mathf.Sin(f) * this.generalLens, Mathf.Cos(f) * this.generalLens);
  684. f = sang + eng * (float)(k + 1) / 20f;
  685. GL.Vertex3(0f, Mathf.Sin(f) * this.generalLens, Mathf.Cos(f) * this.generalLens);
  686. }
  687. }
  688. GL.End();
  689. GL.PopMatrix();
  690. }
  691. private void DrawCircle(Color col, Vector3 vtx, Vector3 vty)
  692. {
  693. GL.Begin(1);
  694. GL.Color(col);
  695. for (int i = 0; i < 100; i++)
  696. {
  697. Vector3 a = vtx * Mathf.Cos(0.06283186f * (float)i);
  698. a += vty * Mathf.Sin(0.06283186f * (float)i);
  699. GL.Vertex3(a.x, a.y, a.z);
  700. a = vtx * Mathf.Cos(0.06283186f * (float)(i + 1));
  701. a += vty * Mathf.Sin(0.06283186f * (float)(i + 1));
  702. GL.Vertex3(a.x, a.y, a.z);
  703. }
  704. GL.End();
  705. }
  706. private float SnapDot(float dot, float x, float y)
  707. {
  708. float result;
  709. if (dot >= 0f)
  710. {
  711. if (y > 0f)
  712. {
  713. result = Mathf.Acos(dot);
  714. }
  715. else
  716. {
  717. result = 6.28318548f - Mathf.Acos(dot);
  718. }
  719. }
  720. else if (y > 0f)
  721. {
  722. result = Mathf.Acos(dot);
  723. }
  724. else
  725. {
  726. result = 6.28318548f - Mathf.Acos(dot);
  727. }
  728. return result;
  729. }
  730. private void DrawCircleHalf(Color col, Vector3 vtx, Vector3 vty)
  731. {
  732. GL.Begin(1);
  733. GL.Color(col);
  734. for (int i = 0; i < 100; i++)
  735. {
  736. Vector3 a = vtx * Mathf.Cos(0.03141593f * (float)i);
  737. a += vty * Mathf.Sin(0.03141593f * (float)i);
  738. GL.Vertex3(a.x, a.y, a.z);
  739. a = vtx * Mathf.Cos(0.03141593f * (float)(i + 1));
  740. a += vty * Mathf.Sin(0.03141593f * (float)(i + 1));
  741. GL.Vertex3(a.x, a.y, a.z);
  742. }
  743. GL.End();
  744. }
  745. private void DrawAxis(Vector3 axis, Vector3 vtx, Vector3 vty, float fct, float fct2, Color col)
  746. {
  747. GL.Begin(1);
  748. GL.Color(col);
  749. GL.Vertex3(0f, 0f, 0f);
  750. GL.Vertex(axis);
  751. GL.End();
  752. GL.Begin(4);
  753. for (int i = 0; i <= 30; i++)
  754. {
  755. Vector3 vector = vtx * Mathf.Cos(0.209439516f * (float)i) * fct;
  756. vector += vty * Mathf.Sin(0.209439516f * (float)i) * fct;
  757. vector += axis * fct2;
  758. GL.Vertex(vector);
  759. vector = vtx * Mathf.Cos(0.209439516f * (float)(i + 1)) * fct;
  760. vector += vty * Mathf.Sin(0.209439516f * (float)(i + 1)) * fct;
  761. vector += axis * fct2;
  762. GL.Vertex(vector);
  763. GL.Vertex(axis);
  764. }
  765. GL.End();
  766. }
  767. private void DrawAxisS(Vector3 axis, Color col)
  768. {
  769. GL.Begin(1);
  770. GL.Color(col);
  771. GL.Vertex3(0f, 0f, 0f);
  772. GL.Vertex(axis);
  773. GL.End();
  774. }
  775. private void DrawFan(Vector3 vtx, Vector3 vty, float ng)
  776. {
  777. for (int i = 0; i <= 50; i++)
  778. {
  779. GL.Begin(4);
  780. GL.Color(this.colorFan);
  781. Vector3 vector = vtx * Mathf.Cos(ng / 50f * (float)i);
  782. vector += vty * Mathf.Sin(ng / 50f * (float)i);
  783. GL.Vertex(vector);
  784. vector = vtx * Mathf.Cos(ng / 50f * (float)(i + 1));
  785. vector += vty * Mathf.Sin(ng / 50f * (float)(i + 1));
  786. GL.Vertex(vector);
  787. GL.Vertex(Vector3.zero);
  788. GL.End();
  789. }
  790. }
  791. private void DrawQuad(float size, bool bSelected, Vector3 axisU, Vector3 axisV, Color col)
  792. {
  793. col.a = 0.3f;
  794. Vector3[] array = new Vector3[]
  795. {
  796. Vector3.zero,
  797. axisU * size,
  798. (axisU + axisV) * size,
  799. axisV * size
  800. };
  801. GL.Begin(7);
  802. if (!bSelected)
  803. {
  804. GL.Color(col);
  805. }
  806. else
  807. {
  808. GL.Color(this.colorWhite);
  809. }
  810. GL.Vertex(array[0]);
  811. GL.Vertex(array[1]);
  812. GL.Vertex(array[2]);
  813. GL.Vertex(array[3]);
  814. GL.End();
  815. col.a = 1f;
  816. if (!bSelected)
  817. {
  818. GL.Color(col);
  819. }
  820. else
  821. {
  822. GL.Color(this.colorWhite);
  823. }
  824. GL.Begin(1);
  825. GL.Vertex(array[0]);
  826. GL.Vertex(array[1]);
  827. GL.Vertex(array[1]);
  828. GL.Vertex(array[2]);
  829. GL.Vertex(array[2]);
  830. GL.Vertex(array[3]);
  831. GL.Vertex(array[3]);
  832. GL.Vertex(array[0]);
  833. GL.End();
  834. }
  835. private void DrawTri(float size, bool bSelected, Vector3 axisU, Vector3 axisV, Color col)
  836. {
  837. col.a = 0.3f;
  838. Vector3[] array = new Vector3[]
  839. {
  840. Vector3.zero,
  841. axisU,
  842. axisV
  843. };
  844. array[1] *= size;
  845. array[2] *= size;
  846. GL.Begin(4);
  847. if (!bSelected)
  848. {
  849. GL.Color(col);
  850. }
  851. else
  852. {
  853. GL.Color(this.colorWhite);
  854. }
  855. GL.Vertex(array[0]);
  856. GL.Vertex(array[1]);
  857. GL.Vertex(array[2]);
  858. GL.End();
  859. col.a = 1f;
  860. if (!bSelected)
  861. {
  862. GL.Color(col);
  863. }
  864. else
  865. {
  866. GL.Color(this.colorWhite);
  867. }
  868. GL.Begin(1);
  869. GL.Vertex(array[0]);
  870. GL.Vertex(array[1]);
  871. GL.Vertex(array[1]);
  872. GL.Vertex(array[2]);
  873. GL.Vertex(array[2]);
  874. GL.Vertex(array[0]);
  875. GL.End();
  876. }
  877. private void DrawCube(float size, bool bSelected, Vector3 center, Vector3 axisU, Vector3 axisV, Color col, GizmoRender.MOVETYPE move)
  878. {
  879. Vector3[] array = new Vector3[8];
  880. center.x -= size / 2f;
  881. center.y -= size / 2f;
  882. center.z -= size / 2f;
  883. array[0] = center;
  884. array[1] = center + axisU * size;
  885. array[2] = center + (axisU + axisV) * size;
  886. array[3] = center + axisV * size;
  887. array[4] = array[0];
  888. if (move == GizmoRender.MOVETYPE.X)
  889. {
  890. Vector3[] array2 = array;
  891. int num = 4;
  892. array2[num].x = array2[num].x + size;
  893. }
  894. if (move == GizmoRender.MOVETYPE.Y)
  895. {
  896. Vector3[] array3 = array;
  897. int num2 = 4;
  898. array3[num2].y = array3[num2].y + size;
  899. }
  900. if (move == GizmoRender.MOVETYPE.Z)
  901. {
  902. Vector3[] array4 = array;
  903. int num3 = 4;
  904. array4[num3].z = array4[num3].z + size;
  905. }
  906. array[5] = array[1];
  907. if (move == GizmoRender.MOVETYPE.X)
  908. {
  909. Vector3[] array5 = array;
  910. int num4 = 5;
  911. array5[num4].x = array5[num4].x + size;
  912. }
  913. if (move == GizmoRender.MOVETYPE.Y)
  914. {
  915. Vector3[] array6 = array;
  916. int num5 = 5;
  917. array6[num5].y = array6[num5].y + size;
  918. }
  919. if (move == GizmoRender.MOVETYPE.Z)
  920. {
  921. Vector3[] array7 = array;
  922. int num6 = 5;
  923. array7[num6].z = array7[num6].z + size;
  924. }
  925. array[6] = array[2];
  926. if (move == GizmoRender.MOVETYPE.X)
  927. {
  928. Vector3[] array8 = array;
  929. int num7 = 6;
  930. array8[num7].x = array8[num7].x + size;
  931. }
  932. if (move == GizmoRender.MOVETYPE.Y)
  933. {
  934. Vector3[] array9 = array;
  935. int num8 = 6;
  936. array9[num8].y = array9[num8].y + size;
  937. }
  938. if (move == GizmoRender.MOVETYPE.Z)
  939. {
  940. Vector3[] array10 = array;
  941. int num9 = 6;
  942. array10[num9].z = array10[num9].z + size;
  943. }
  944. array[7] = array[3];
  945. if (move == GizmoRender.MOVETYPE.X)
  946. {
  947. Vector3[] array11 = array;
  948. int num10 = 7;
  949. array11[num10].x = array11[num10].x + size;
  950. }
  951. if (move == GizmoRender.MOVETYPE.Y)
  952. {
  953. Vector3[] array12 = array;
  954. int num11 = 7;
  955. array12[num11].y = array12[num11].y + size;
  956. }
  957. if (move == GizmoRender.MOVETYPE.Z)
  958. {
  959. Vector3[] array13 = array;
  960. int num12 = 7;
  961. array13[num12].z = array13[num12].z + size;
  962. }
  963. GL.Begin(7);
  964. if (!bSelected)
  965. {
  966. GL.Color(col);
  967. }
  968. else
  969. {
  970. GL.Color(this.colorWhite);
  971. }
  972. GL.Vertex(array[0]);
  973. GL.Vertex(array[1]);
  974. GL.Vertex(array[2]);
  975. GL.Vertex(array[3]);
  976. GL.Vertex(array[4]);
  977. GL.Vertex(array[5]);
  978. GL.Vertex(array[6]);
  979. GL.Vertex(array[7]);
  980. GL.Vertex(array[1]);
  981. GL.Vertex(array[5]);
  982. GL.Vertex(array[6]);
  983. GL.Vertex(array[2]);
  984. GL.Vertex(array[0]);
  985. GL.Vertex(array[4]);
  986. GL.Vertex(array[7]);
  987. GL.Vertex(array[3]);
  988. GL.Vertex(array[0]);
  989. GL.Vertex(array[1]);
  990. GL.Vertex(array[5]);
  991. GL.Vertex(array[4]);
  992. GL.Vertex(array[3]);
  993. GL.Vertex(array[2]);
  994. GL.Vertex(array[6]);
  995. GL.Vertex(array[7]);
  996. GL.End();
  997. }
  998. public static bool global_control_lock;
  999. private static bool local_control_lock_;
  1000. public Material lineMaterial;
  1001. private Vector3 untransRight;
  1002. private Vector3 untransUp;
  1003. private Vector3 untransForward;
  1004. private Vector3 Dir;
  1005. private Color colorRed;
  1006. private Color colorGreen;
  1007. private Color colorBlue;
  1008. private Color colorFan;
  1009. private Color colorWhite;
  1010. private Color colorLine;
  1011. private Color colorWire;
  1012. private Color selX;
  1013. private Color selY;
  1014. private Color selZ;
  1015. private Color panY;
  1016. private Color panX;
  1017. private Color panZ;
  1018. private Color circleX;
  1019. private Color circleY;
  1020. private Color circleZ;
  1021. private Plane planeXZ;
  1022. private Plane planeYZ;
  1023. private Plane planeXY;
  1024. public float lineSelectedThick = 0.04f;
  1025. public float lineRSelectedThick = 0.1f;
  1026. private float generalLens = 1f;
  1027. private GizmoRender.MOVETYPE beSelectedType;
  1028. private Vector3 hitMouseDown;
  1029. private Vector3 hitMouseMove;
  1030. private bool moveLockVertex;
  1031. private Matrix4x4 locklocalToWorldMatrix;
  1032. private float rotaCal;
  1033. private Vector3 matScal;
  1034. private Matrix4x4 rotationMatrix;
  1035. private Vector3 uForward;
  1036. private Vector3 rForward;
  1037. private Vector3 fForward;
  1038. public bool Visible = true;
  1039. public bool VisibleRotateX = true;
  1040. public bool VisibleRotateY = true;
  1041. public bool VisibleRotateZ = true;
  1042. public static bool UIVisible = true;
  1043. public bool eAxis;
  1044. public bool eRotate;
  1045. public bool eScal;
  1046. private Vector3 oScal;
  1047. private static RaycastHit ray_hit_;
  1048. private static bool ray_check_;
  1049. private static bool ui_ray_check_;
  1050. private static bool is_drag_;
  1051. public float offsetScale = 1f;
  1052. private enum MOVETYPE
  1053. {
  1054. NONE,
  1055. X,
  1056. X2,
  1057. Y,
  1058. Y2,
  1059. Z,
  1060. Z2,
  1061. XZ,
  1062. YZ,
  1063. XY,
  1064. RX,
  1065. RY,
  1066. RZ,
  1067. TX,
  1068. TY,
  1069. TZ,
  1070. TX2,
  1071. TY2,
  1072. TZ2,
  1073. TXY,
  1074. TXZ,
  1075. TYZ
  1076. }
  1077. }