llmaniprotate.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /**
  2. * @file llmaniprotate.h
  3. * @brief LLManipRotate class definition
  4. *
  5. * $LicenseInfo:firstyear=2002&license=viewergpl$
  6. *
  7. * Copyright (c) 2002-2009, Linden Research, Inc.
  8. *
  9. * Second Life Viewer Source Code
  10. * The source code in this file ("Source Code") is provided by Linden Lab
  11. * to you under the terms of the GNU General Public License, version 2.0
  12. * ("GPL"), unless you have obtained a separate licensing agreement
  13. * ("Other License"), formally executed by you and Linden Lab. Terms of
  14. * the GPL can be found in doc/GPL-license.txt in this distribution, or
  15. * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  16. *
  17. * There are special exceptions to the terms and conditions of the GPL as
  18. * it is applied to this Source Code. View the full text of the exception
  19. * in the file doc/FLOSS-exception.txt in this software distribution, or
  20. * online at
  21. * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  22. *
  23. * By copying, modifying or distributing this software, you acknowledge
  24. * that you have read and understood your obligations described above,
  25. * and agree to abide by those obligations.
  26. *
  27. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  28. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  29. * COMPLETENESS OR PERFORMANCE.
  30. * $/LicenseInfo$
  31. */
  32. #ifndef LL_LLMANIPROTATE_H
  33. #define LL_LLMANIPROTATE_H
  34. #include "llquaternion.h"
  35. #include "llvector3.h"
  36. #include "llvector4.h"
  37. #include "llmanip.h"
  38. #include "lltool.h"
  39. #include "llviewerobject.h"
  40. class LLToolComposite;
  41. class LLColor4;
  42. class LLManipRotate : public LLManip
  43. {
  44. protected:
  45. LOG_CLASS(LLManipRotate);
  46. public:
  47. class ManipulatorHandle
  48. {
  49. public:
  50. LLVector3 mAxisU;
  51. LLVector3 mAxisV;
  52. U32 mManipID;
  53. ManipulatorHandle(LLVector3 axis_u, LLVector3 axis_v, U32 id)
  54. : mAxisU(axis_u),
  55. mAxisV(axis_v),
  56. mManipID(id)
  57. {
  58. }
  59. };
  60. LLManipRotate(LLToolComposite* composite);
  61. virtual bool handleMouseDown(S32 x, S32 y, MASK mask);
  62. virtual bool handleMouseUp(S32 x, S32 y, MASK mask);
  63. virtual bool handleHover(S32 x, S32 y, MASK mask);
  64. virtual void render();
  65. virtual void handleSelect();
  66. virtual bool handleMouseDownOnPart(S32 x, S32 y, MASK mask);
  67. virtual void highlightManipulators(S32 x, S32 y);
  68. virtual bool canAffectSelection();
  69. private:
  70. void updateHoverView();
  71. void drag(S32 x, S32 y);
  72. LLVector3 projectToSphere(F32 x, F32 y, bool* on_sphere);
  73. void renderSnapGuides();
  74. void renderActiveRing(F32 radius, F32 width,
  75. const LLColor4& center_color,
  76. const LLColor4& side_color);
  77. bool updateVisiblity();
  78. LLVector3 findNearestPointOnRing(S32 x, S32 y,
  79. const LLVector3& center,
  80. const LLVector3& axis);
  81. LLQuaternion dragUnconstrained(S32 x, S32 y);
  82. LLQuaternion dragConstrained(S32 x, S32 y);
  83. LLVector3 getConstraintAxis();
  84. S32 getObjectAxisClosestToMouse(LLVector3& axis);
  85. // Utility functions
  86. static bool getSnapEnabled();
  87. static void mouseToRay(S32 x, S32 y, LLVector3* ray_pt,
  88. LLVector3* ray_dir);
  89. static LLVector3 intersectMouseWithSphere(S32 x, S32 y,
  90. const LLVector3& sphere_center,
  91. F32 sphere_radius);
  92. static LLVector3 intersectRayWithSphere(const LLVector3& ray_pt,
  93. const LLVector3& ray_dir,
  94. const LLVector3& sphere_center,
  95. F32 sphere_radius);
  96. private:
  97. LLVector3d mRotationCenter;
  98. LLCoordGL mCenterScreen;
  99. LLQuaternion mRotation;
  100. LLVector3 mMouseDown;
  101. LLVector3 mMouseCur;
  102. F32 mRadiusMeters;
  103. LLVector3 mCenterToCam;
  104. LLVector3 mCenterToCamNorm;
  105. F32 mCenterToCamMag;
  106. LLVector3 mCenterToProfilePlane;
  107. F32 mCenterToProfilePlaneMag;
  108. LLVector4 mManipulatorVertices[6];
  109. LLVector4 mManipulatorScales;
  110. bool mSmoothRotate;
  111. bool mCamEdgeOn;
  112. };
  113. #endif // LL_LLMANIPROTATE_H