diff options
| author | jpbruyere <jp.bruyere@hotmail.com> | 2017-01-24 12:46:43 +0100 |
|---|---|---|
| committer | jpbruyere <jp.bruyere@hotmail.com> | 2017-01-24 12:46:43 +0100 |
| commit | d8acaa909ce73e150827db9846cd8690fb93d68e (patch) | |
| tree | c22aab77a5851aad79505a49dc6ac91ca4b0a106 /Tests | |
| parent | e39ac936765e88382d858ee6922293315a18b60d (diff) | |
| parent | 1a4fe8bd37ed4a3e3324a134df4f90c14b315918 (diff) | |
Merge branch 'master' into CrowIDE
Diffstat (limited to 'Tests')
| -rw-r--r-- | Tests/CrowWindow.cs | 8 | ||||
| -rw-r--r-- | Tests/InterfaceControler.cs | 33 | ||||
| -rw-r--r-- | Tests/OpenGL/Extensions.cs | 23 |
3 files changed, 39 insertions, 25 deletions
diff --git a/Tests/CrowWindow.cs b/Tests/CrowWindow.cs index 07f6ab79..068e94d2 100644 --- a/Tests/CrowWindow.cs +++ b/Tests/CrowWindow.cs @@ -186,6 +186,14 @@ namespace Crow new Rectangle (0, 0, this.ClientRectangle.Width, this.ClientRectangle.Height))); return ifaceControl [interfaceIdx].CrowInterface.LoadInterface (path); } + public GraphicObject FindByName (string nameToFind){ + for (int i = 0; i < ifaceControl.Count; i++) { + GraphicObject tmp = ifaceControl [i].CrowInterface.FindByName (nameToFind); + if (tmp != null) + return tmp; + } + return null; + } public void ClearInterface (int interfaceIdx = 0){ ifaceControl [interfaceIdx].CrowInterface.ClearInterface (); } diff --git a/Tests/InterfaceControler.cs b/Tests/InterfaceControler.cs index 6cb13b2f..12ddf7d8 100644 --- a/Tests/InterfaceControler.cs +++ b/Tests/InterfaceControler.cs @@ -53,7 +53,12 @@ namespace Crow public override void ProcessResize (Rectangle newSize) { } - + public override void OpenGLDraw () + { + GL.Enable (EnableCap.DepthTest); + base.OpenGLDraw (); + GL.Disable (EnableCap.DepthTest); + } public void UpdateView (Matrix4 _projection, Matrix4 _modelview, int[] _viewport, Vector3 _vEyePosition) { projection = _projection; @@ -64,7 +69,7 @@ namespace Crow public override bool ProcessMouseMove (int x, int y) { Matrix4 mv = ifaceModelMat * modelview; - Vector3 vMouse = Extensions.UnProject(ref projection, ref mv, viewport, new Vector2 (x, y)).Xyz; + Vector3 vMouse = UnProject(ref projection, ref mv, viewport, new Vector2 (x, y)).Xyz; Vector3 vE = vEyePosition.Transform (ifaceModelMat.Inverted()); Vector3 vMouseRay = Vector3.Normalize(vMouse - vE); float a = vE.Z / vMouseRay.Z; @@ -76,6 +81,30 @@ namespace Crow return mouseIsInInterface ? CrowInterface.ProcessMouseMove (localMousePos.X, localMousePos.Y) : false; } + Vector4 UnProject(ref Matrix4 projection, ref Matrix4 view, int[] viewport, Vector2 mouse) + { + Vector4 vec; + + vec.X = 2.0f * mouse.X / (float)viewport[2] - 1; + vec.Y = -(2.0f * mouse.Y / (float)viewport[3] - 1); + vec.Z = 0f; + vec.W = 1.0f; + + Matrix4 viewInv = Matrix4.Invert(view); + Matrix4 projInv = Matrix4.Invert(projection); + + Vector4.Transform(ref vec, ref projInv, out vec); + Vector4.Transform(ref vec, ref viewInv, out vec); + + if (vec.W > float.Epsilon || vec.W < float.Epsilon) + { + vec.X /= vec.W; + vec.Y /= vec.W; + vec.Z /= vec.W; + } + + return vec; + } } public class InterfaceControler { public Interface CrowInterface; diff --git a/Tests/OpenGL/Extensions.cs b/Tests/OpenGL/Extensions.cs index 17fe6086..0dd1cca6 100644 --- a/Tests/OpenGL/Extensions.cs +++ b/Tests/OpenGL/Extensions.cs @@ -35,30 +35,7 @@ namespace Crow public static bool IsInBetween(this int v, int min, int max){ return v >= min & v <= max; } - public static Vector4 UnProject(ref Matrix4 projection, ref Matrix4 view, int[] viewport, Vector2 mouse) - { - Vector4 vec; - vec.X = 2.0f * mouse.X / (float)viewport[2] - 1; - vec.Y = -(2.0f * mouse.Y / (float)viewport[3] - 1); - vec.Z = 0f; - vec.W = 1.0f; - - Matrix4 viewInv = Matrix4.Invert(view); - Matrix4 projInv = Matrix4.Invert(projection); - - Vector4.Transform(ref vec, ref projInv, out vec); - Vector4.Transform(ref vec, ref viewInv, out vec); - - if (vec.W > float.Epsilon || vec.W < float.Epsilon) - { - vec.X /= vec.W; - vec.Y /= vec.W; - vec.Z /= vec.W; - } - - return vec; - } } } |