SceneView.txt 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. TODO:
  2. - Core thread gets stuck on shutdown when OpenGL is used...Somewhere in kernel
  3. CONCRETE TASK:
  4. - Hook up gizmo manager to ScenePicking so gizmos are considered when picking
  5. - I'll likely need to update GizmoManager so I can query gizmo SceneObject based on gizmo index
  6. - Selection/ScenePicking/GizmoManager need to be started
  7. IMMEDIATE:
  8. - SceneGrid is very ugly. Consider using default lines for now and come back with a better approach later.
  9. - Potentially enable line AA?
  10. - Picking code is completely untested and will likely need major fixing
  11. - Test all the new DrawHelper3D methods
  12. GIZMO TODO:
  13. - Figure out how to deal with builtin components like Camera and Renderable (e.g. how will they have gizmos since they're not managed components?)
  14. LATER:
  15. - Need a way to render text for gizmos and handles, and in scene in general
  16. ----------------------------------------------------------------------
  17. Handles
  18. SliderLine - position, direction, length
  19. - When initially activated it records position nearest so the line as the starting point
  20. - Further mouse dragging also finds nearest position to the line
  21. - Difference between those two results in a float value (how much to move along direction from position to reach new position)
  22. - Slider line has a capsule + sphere collider size of which can be set manually
  23. SliderPlane - position, normal, size
  24. - Similar to line slider only the direction is determined dynamically as well as distance
  25. - Outputs a Vector2 (direction * distance moved)
  26. - A OOB is used as a collider
  27. SliderDisc - position, normal, radius
  28. - When initially activated it records position nearest so the disc as the starting point
  29. - Further movement calculates the dynamic direction from the starting point to the current point on the plane the disc lies on
  30. - Distance along that direction is returned as amount of movement (similar to line slider)
  31. - Outputs a single float
  32. - A torus is used as a collider
  33. Free move/rotate/scale handles need to exist as well
  34. - Scale is easy, just perform uniform scale. Use SliderPlane oriented towards camera
  35. - Move also use SliderPlane oriented towards camera
  36. - Rotation use SliderDisc oriented towards camera
  37. CONCRETE TODO:
  38. HandleSliderManager
  39. - Detecting input and updating the sliders
  40. - isHandleActive
  41. ScriptHandleManager
  42. - Pretty much everything (in more detail in .cpp file)
  43. - Needs to be started up somewhere
  44. C# Component needs "sceneObject" property
  45. C# SceneObject needs position/rot/scale (and local variants) properties
  46. SceneEditorWidget
  47. - Need to glue everything together
  48. More complex handles (combinations of sliders + draw methods)
  49. - In C#, called by ScriptHandleManager
  50. Nearest point to disc/arc code
  51. More complex types for drawing like DrawArrow in HandleDrawManager
  52. Handles that remain the same size regardless of distance from camera
  53. - For both drawing and collision
  54. Consider local vs. global handle mode
  55. OPEN QUESTIONS:
  56. - How to handle handles with multiple selection?
  57. EXAMPLE:
  58. [CustomHandle(typeof(Camera))]
  59. class CameraHandle : IHandle
  60. {
  61. SliderLine xAxis;
  62. SliderLine yAxis;
  63. CameraHandle()
  64. {
  65. xAxis = new SliderLine(Vector3.right, 10.0f);
  66. yAxis = new SliderLine(Vector3.up, 10.0f);
  67. xAxis.onDragged += onXAxis();
  68. yAxis.onDragged += onYAxis();
  69. }
  70. void onXAxis()
  71. {
  72. // Here I can decide whether or not I want to use handle data or not, per object instance
  73. target.position = xAxis.getMove(target.position);
  74. }
  75. void onYAxis()
  76. {
  77. target.position = yAxis.getMove(target.position);
  78. }
  79. void Update()
  80. {
  81. // Resize handle, change matrix, etc.
  82. }
  83. void Draw()
  84. {
  85. xAxis.Draw();
  86. HandleDraw.Arrow(target.position, Vector3.right, 10.0f);
  87. HandleDraw.Arrow(target.position, Vector3.up, 10.0f);
  88. }
  89. }
  90. ----------------------------------------------------------------------
  91. SelectionRenderer
  92. Retrieve a list of selected objects from SelectionManager
  93. Find ones with Renderable components
  94. Retrieve Meshes, and world transforms from them
  95. Draw that same mesh with either a wireframe or a grayed out shader with a slight depth bias
  96. ----------------------------------------------------------------------
  97. SceneView editor flow:
  98. Hook up gizmo, handle and selection rendering methods to be executed after the scene is rendered
  99. Calculate mouse coords manually relative to the window and to the render texture GUI element
  100. - Don't use GUI events as we require more precise control (do we?)
  101. Detect mouse clicks on the scene render target
  102. Forward those mouse coordinates to HandleManager
  103. It checks if screen ray intersects any handles and returns the handle if it does
  104. If handle is found it is activated and method returns
  105. Otherwise we mark the coordinates as selection start
  106. Detect mouse drag on the scene render target
  107. - If we have an active handle
  108. Forward mouse coordinates to the active handle so it can do its thing
  109. return
  110. - Otherwise its assumed we are dragging a selection
  111. Update selection endpoint and send it to ScenePicking
  112. Use Selection to select picked objects if any
  113. return
  114. Detect mouse release on scene render target
  115. If we have an active handle
  116. Clear active handle
  117. return
  118. Otheriwse its assumed we are dragging a selection
  119. Do nothing
  120. return