API Documentation
Loading...
Searching...
No Matches
GeometryMaker.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------------------------------
2Copyright (c) 2019, NDEVR LLC
3tyler.parke@ndevr.org
4 __ __ ____ _____ __ __ _______
5 | \ | | | __ \ | ___|\ \ / / | __ \
6 | \ | | | | \ \ | |___ \ \ / / | |__) |
7 | . \| | | |__/ / | |___ \ V / | _ /
8 | |\ |_|_____/__|_____|___\_/____| | \ \
9 |__| \__________________________________| \__\
10
11Subject to the terms of the Enterprise+ Agreement, NDEVR hereby grants
12Licensee a limited, non-exclusive, non-transferable, royalty-free license
13(without the right to sublicense) to use the API solely for the purpose of
14Licensee's internal development efforts to develop applications for which
15the API was provided.
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
21INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
22PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
23FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25DEALINGS IN THE SOFTWARE.
26
27Library: Design
28File: GeometryMaker
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include <NDEVR/SnapController.h>
34#if NDEVR_VIEWPORT
35#include <NDEVR/CommandLockObject.h>
36namespace NDEVR
37{
38 /**--------------------------------------------------------------------------------------------------
39 \brief A controller for creating basic geometry with the mouse such as polylines, circles, or spheres
40 TODO: Allow existing models to be used here.
41 *-----------------------------------------------------------------------------------------------**/
42 class NDEVR_DESIGN_API GeometryMaker : public SnapController
43 {
44 class KeyManager;
45 public:
46 enum GeometryCreateMode : uint04
47 {
48 e_no_creation
49 , e_draw_points
50 , e_draw_lines
51 , e_draw_polyline
52 , e_draw_spline
53 , e_draw_triangles
54 , e_draw_circle
55 , e_draw_conic_arc
56 , e_draw_oval
57 , e_draw_square
58 , e_draw_rectangle
59 , e_draw_polygon
60 , e_draw_sphere
61 , e_draw_cylinder
62 , e_draw_cone
63 , e_draw_box
64 , e_create_mode_size
65 };
66 enum GeometrySpecMode : uint04
67 {
69 , e_edge
70 , e_corner
71 , e_orient
72 , e_normal
74 , e_spec_mode_size
75 };
76 struct GeoStructure
77 {
78 Vertex<3, fltp08> center = Constant<Vector<3, fltp08>>::Invalid;
79 Ray<3, fltp08> normal = Constant<Vector<3, fltp08>>::Invalid;
80 Vertex<3, fltp08> edge[4] = { Constant<Vector<3, fltp08>>::Invalid, Constant<Vector<3, fltp08>>::Invalid, Constant<Vector<3, fltp08>>::Invalid, Constant<Vector<3, fltp08>>::Invalid };
81 Vertex<3, fltp08> corner[4] = { Constant<Vector<3, fltp08>>::Invalid, Constant<Vector<3, fltp08>>::Invalid, Constant<Vector<3, fltp08>>::Invalid, Constant<Vector<3, fltp08>>::Invalid };
82 Vertex<3, fltp08> plane[4] = { Constant<Vector<3, fltp08>>::Invalid, Constant<Vector<3, fltp08>>::Invalid, Constant<Vector<3, fltp08>>::Invalid, Constant<Vector<3, fltp08>>::Invalid };
83 uint04 num_of_points = 0;
84 };
85
86 GeometryMaker(DesignObjectLookup* manager);
87
88 virtual void begin() override;
89 void createNewModel();
90 virtual void finish() override;
91 virtual void cancel() override;
92
93 const UUID& material() const { return m_default_material; }
94 const UUID& rootModel() const { return m_root_model; }
95 const UUID& currentModel() const { return m_current_model; }
96 void deleteAllCreatedModels();
97 void setGenerateNormals(bool generate_normals);
98 void setAutoWind(bool auto_wind_shapes);
99 void setRootModel(UUID model, UUID material = Constant<UUID>::Invalid);
100 void setIsTouch(bool touch_mode);
101 bool tryCommandLock();
102 bool hasCommandLock();
103 void calculateSolid(Geometry& mesh);
104 virtual void addPoint(const SnapPoint& point) override;
105 void lockMovement(bool lock_movement) { m_lock_movement = lock_movement; }
106 bool movementLocked() const { return m_lock_movement; }
107 uint04 currentStep() const;
108 uint04 numberOfSteps() const;
109 const Buffer<UUID>& createdModels() { return m_created_models; }
110 void setSpecMode(const Buffer<GeometrySpecMode>& spec_mode) { m_spec_mode = spec_mode; };
111 const Buffer<GeometrySpecMode>& specMode() { return m_spec_mode; }
112 TranslatedString getHint() const;
113 virtual void updateLocation(const Vertex<3, fltp08>& location, bool is_select, Camera* camera) override;
114 Resource<GeometryCreateMode> create_mode;
115 protected:
116 void createRootModel();
117 virtual SelectionInfo createSelectionInfo(const MouseEvent& event, Camera* camera) override;
118 void updatePrimitive(const Vertex<3, fltp08>& world_location);
119 void onSelect(Camera* camera);
120 static Vector<3, Angle<fltp08>> getOrientation(const Vector<3, fltp08>& lookat, const Vector<3, fltp08>& up);
121 virtual bool processMouseEvent(const MouseEvent& mouse_event, DesignObjectLookup* lookup, Camera* camera) override;
122 virtual bool processKeyEvent(const KeyEvent& event, DesignObjectLookup* lookup, Camera* camera) override;
123 void processResizeEvent(const GeoStructure& spec, Model& model, Camera* camera);
124 void setupDefaultMaterial();
125 protected:
126 CommandLockObject m_command_lock;
127 Plane<3, fltp08> m_draw_plane;
128 UUID m_default_material;
129 UUID m_current_model;
130 UUID m_root_model;
131 uint04 m_num_created[e_create_mode_size] = { 0,0,0,0,0,0,0,0,0,0,0,0,0 };
132 uint04 m_num_roots_created = 0;
133 Buffer<UUID> m_created_models;
134 Buffer<GeometrySpecMode> m_spec_mode;
135 bool m_auto_wind_shapes;
136 bool m_generate_normals;
137 bool m_lock_movement;
138 bool m_is_moving;
139 bool m_is_touch_mode;
140 };
141}
142#endif
#define NDEVR_DESIGN_API
Definition DLLInfo.h:77
Definition ACIColor.h:37
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:94