Gamp v0.0.7-54-gccdc599
Gamp: Graphics, Audio, Multimedia and Processing
Loading...
Searching...
No Matches
Shape.hpp
Go to the documentation of this file.
1/*
2 * Author: Sven Gothel <sgothel@jausoft.com> (C++, Java) and Rami Santina (Java)
3 * Copyright Gothel Software e.K. and the authors
4 *
5 * SPDX-License-Identifier: MIT
6 *
7 * This Source Code Form is subject to the terms of the MIT License
8 * If a copy of the MIT was not distributed with this file,
9 * you can obtain one at https://opensource.org/license/mit/.
10 */
11#ifndef JAU_GAMP_GRAPH_UI_SHAPE_HPP_
12#define JAU_GAMP_GRAPH_UI_SHAPE_HPP_
13
14#include <jau/basic_types.hpp>
15#include <jau/darray.hpp>
16#include <jau/float_math.hpp>
17#include <jau/float_types.hpp>
18#include <jau/int_types.hpp>
19#include <jau/enum_util.hpp>
20#include <jau/fraction_type.hpp>
23#include <jau/math/vec3f.hpp>
24#include <jau/math/vec4f.hpp>
25#include <jau/math/vec4f.hpp>
28
30#include <gamp/GampTypes.hpp>
31#include <gamp/Gamp.hpp>
36#include <mutex>
37
38namespace gamp::graph::ui {
39
40 using namespace jau::math;
41 using namespace jau::math::util;
42 using namespace jau::math::geom;
43
44 using namespace gamp::wt;
45 using namespace gamp::wt::event;
46
47 using namespace gamp::graph;
48
49 using namespace jau::int_literals;
50
51 using namespace jau::enums;
52
53 /** \addtogroup Gamp_GraphUI
54 *
55 * @{
56 */
57
58 namespace impl {
59 enum class IOState : uint32_t {
60 none = 0,
61 visible = 1_u32 << 0,
62 interactive = 1_u32 << 1,
63 activable = 1_u32 << 2,
64 toggleable = 1_u32 << 3,
65 draggable = 1_u32 << 4,
66 resizable = 1_u32 << 5,
67 resize_fixed_ratio = 1_u32 << 6,
68 active = 1_u32 << 7,
69 discarded = 1_u32 << 25,
70 down = 1_u32 << 26,
71 toggle = 1_u32 << 27,
72 drag_first = 1_u32 << 28,
73 in_move = 1_u32 << 29,
74 in_resize_br = 1_u32 << 30,
75 in_resize_bl = 1_u32 << 31
76 };
80 }
81
82 class Shape {
83 public:
84 /**
85 * Visitor1 method
86 * @param s the {@link Shape} to process
87 * @return true to signal operation complete and to stop traversal, otherwise false
88 */
90
91 /**
92 * Visitor2 method
93 * @param s the {@link Shape} to process
94 * @param pmv the {@link PMVMatrix4f} setup from the {@link Scene} down to the {@link Shape}
95 * @return true to signal operation complete and to stop traversal, otherwise false
96 */
98
99 /**
100 * {@link Shape} move listener
101 * @param s the moved shape
102 * @param origin original position, relative object coordinates to the associated {@link Shape}
103 * @param dest new position, relative object coordinates to the associated {@link Shape}
104 * @param e original Newt {@link MouseEvent}
105 */
106 typedef jau::function<void(ShapeRef& s, const Vec3f& origin, const Vec3f& dest, const PointerEvent& e)> MoveEventCallback;
107
108 /**
109 * {@link Shape} pointer listener, e.g. for {@link Shape#onClicked(PointerListener)}
110 * @param s the associated {@link Shape} for this event
111 * @param pos relative object coordinates to the associated {@link Shape}
112 * @param e original Newt {@link MouseEvent}
113 */
114 typedef jau::function<void(ShapeRef& s, const Vec3f& pos, const PointerEvent& e)> PointerEventCallback;
115
116 /**
117 * General {@link Shape} listener action
118 */
120
121 /**
122 * {@link Shape} draw listener action returning a boolean value
123 * <p>
124 * If {@link #run(Shape, GL2ES2, RegionRenderer)} returns {@code true},
125 * the listener will be removed at {@link Shape#draw(GL2ES2, RegionRenderer)}
126 * otherwise kept calling.
127 * </p>
128 *
129 * Return {@code true} to remove this {@link DrawListener} at {@link Shape#draw(GL2ES2, RegionRenderer)},
130 * otherwise it is being kept and called.
131 * @param shape The shape
132 * @param gl the current {@link GL2ES2} object
133 * @param renderer the {@link RegionRenderer}
134 */
135 // FIXME typedef jau::function<void(ShapeRef& s, RenderContext& rc, GraphRenderer& renderer)> DrawEventCallback;
136
137 constexpr static const uint32_t DIRTY_SHAPE = 1_u32 << 0 ;
138 constexpr static const uint32_t DIRTY_STATE = 1_u32 << 1 ;
139
140 protected:
142
143 /** Default base-color w/o color channel, will be modulated w/ pressed- and toggle color */
144 constexpr static Vec4f rgbaColor = Vec4f(0.60f, 0.60f, 0.60f, 1.0f);
145 /** Default pressed color-factor (darker and slightly transparent), modulates base-color. ~0.65 (due to alpha) */
146 constexpr static Vec4f pressedRGBAModulate = Vec4f(0.70f, 0.70f, 0.70f, 0.8f);
147 /** Default toggle color-factor (darker), modulates base-color. 0.60 * 0.83 ~= 0.50 */
148 constexpr static Vec4f toggleOnRGBAModulate = Vec4f(0.83f, 0.83f, 0.83f, 1.0f);
149 /** Default toggle color-factor (original), modulates base-color. 0.60 * 1.00 ~= 0.60 */
150 constexpr static Vec4f toggleOffRGBAModulate = Vec4f(1.00f, 1.00f, 1.00f, 1.0f);
151 /** Default active color-factor (dark), modulates base-color. 0.60 * 0.25 ~= 0.15 */
152 constexpr static Vec4f activeRGBAModulate = Vec4f(0.25f, 0.25f, 0.25f, 1.0f);
153 constexpr static Vec4f cWhite = Vec4f(1, 1, 1, 1);
154
156
157 private:
158 // volatile Group parent = null;
159
160 OutlineShape m_outlines;
161
162 Vec3f m_position;
163 Quat4f m_rotation;
164 Vec3f m_rotPivot;
165 Vec3f m_scale = Vec3f(1, 1, 1);
166 float m_zOffset;
167 Vec4f m_color = Vec4f(0, 0, 0, 1);
168
169 Mat4f iMat;
170 Mat4f tmpMat;
171 bool iMatIdent = true;
172 bool iMatDirty = false;
173
175 std::mutex dirtySync;
176
177 Vec4f m_rgba_tmp = Vec4f(0, 0, 0, 1);
178
181
183 jau::cow_darray<PointerListenerRef> m_pointerListener;
184
185 protected:
186 //
187 //
188 //
189
190 virtual void validateImpl(const render::gl::GL& gl, const render::gl::GLProfile& glp) noexcept;
191
192 /**
193 * Actual draw implementation, called by {@link #draw(GL2ES2, RegionRenderer)}
194 * @param gl
195 * @param renderer
196 * @param rgba
197 */
198 virtual void drawImpl0(const render::gl::GL& gl, RegionRenderer& renderer, const Vec4f& rgba) noexcept;
199
200 /**
201 * Actual draw implementation, called by {@link #drawToSelect(GL2ES2, RegionRenderer)}
202 * @param gl
203 * @param renderer
204 */
205 virtual void drawToSelectImpl0(const render::gl::GL& gl, RegionRenderer& renderer);
206
207 /** Custom {@link #clear(GL2ES2, RegionRenderer)} task, called 1st. */
208 virtual void clearImpl0(const render::gl::GL& gl, RegionRenderer& renderer);
209
210 /** Custom {@link #destroy(GL2ES2, RegionRenderer)} task, called 1st. */
211 virtual void destroyImpl0(const render::gl::GL& gl, RegionRenderer& renderer);
212
213 public:
214 /**
215 * Returns true if implementation uses an extra color channel or texture
216 * which will be modulated with the passed rgba color {@link #drawImpl0(GL2ES2, RegionRenderer, float[])}.
217 *
218 * Otherwise the base color will be modulated and passed to {@link #drawImpl0(GL2ES2, RegionRenderer, float[])}.
219 */
220 virtual bool hasColorChannel() const noexcept;
221
223 : m_outlines()
224 { }
225
226 virtual Container* asContainer() const noexcept { return nullptr; }
227
228 constexpr const Vec3f& position() const noexcept { return m_position; }
229 constexpr Vec3f& position() noexcept { iMatDirty=true; return m_position; }
230
231 constexpr const float& zOffset() const noexcept { return m_zOffset; }
232 constexpr float& zOffset() noexcept { iMatDirty=true; return m_zOffset; }
233
234 constexpr const Quat4f& rotation() const noexcept { return m_rotation; }
235 constexpr Quat4f& rotation() noexcept { iMatDirty=true; return m_rotation; }
236
237 constexpr const Vec3f& rotationPivot() const noexcept { return m_rotPivot; }
238 constexpr Vec3f& rotationPivot() noexcept { iMatDirty=true; return m_rotPivot; }
239
240 constexpr const Vec3f& scale() const noexcept { return m_scale; }
241 constexpr Vec3f& scale() noexcept { iMatDirty=true; return m_scale; }
242
243 constexpr const OutlineShape& outlines() const noexcept { return m_outlines; }
244 constexpr OutlineShape& outlines() noexcept { return m_outlines; }
245
246 constexpr const Vec4f& color() const noexcept { return m_color; }
247 constexpr void setColor(const Vec4f& c) noexcept { m_color=c; }
248
249 //
250 // Input
251 //
252
253 Shape& setPressed(bool b) noexcept {
254 write(m_ioState, impl::IOState::down, b);
255 markStateDirty();
256 return *this;
257 }
258 bool isPressed() const noexcept { return is_set(m_ioState, impl::IOState::down); }
259
260 /**
261 * Set this shape toggleable, default is off.
262 * @param toggleable
263 * @see #isInteractive()
264 */
265 Shape& setToggleable(bool toggleable) noexcept {
266 write(m_ioState, impl::IOState::toggleable, toggleable);
267 return *this;
268 }
269
270 /**
271 * Returns true if this shape is toggable,
272 * i.e. rendered w/ {@link #setToggleOnColorMod(float, float, float, float)} or {@link #setToggleOffColorMod(float, float, float, float)}.
273 * @see #isInteractive()
274 */
275 bool isToggleable() const noexcept { return is_set(m_ioState, impl::IOState::toggleable); }
276
277 /**
278 * Renders the shape.
279 * <p>
280 * {@link #applyMatToMv(PMVMatrix4f)} is expected to be completed beforehand.
281 * </p>
282 * @param gl the current GL object
283 * @param renderer {@link RegionRenderer} which might be used for Graph Curve Rendering, also source of {@link RegionRenderer#getMatrix()} and {@link RegionRenderer#getViewport()}.
284 */
285 void draw(render::gl::GL& gl, RegionRenderer& renderer) noexcept {
286 const bool _isPressed = isPressed(), _isToggleOn = isToggleOn();
287 final Vec4f rgba;
288 if( hasColorChannel() ) {
289 if( isPressed ) {
290 rgba = pressedRGBAModulate;
291 } else if( isToggleable() ) {
292 if( isToggleOn ) {
294 } else {
296 }
297 } else if( activeRGBAModulateOn && isActive() ) {
298 rgba = activeRGBAModulate;
299 } else {
300 rgba = cWhite;
301 }
302 } else {
303 rgba = rgba_tmp;
304 if( isPressed ) {
306 } else if( isToggleable() ) {
307 if( isToggleOn ) {
309 } else {
311 }
312 } else if( activeRGBAModulateOn && isActive() ) {
314 } else {
315 rgba.set(rgbaColor);
316 }
317 }
318 synchronized ( dirtySync ) {
319 validate(gl);
320 drawImpl0(gl, renderer, rgba);
321 }
322 if( null != onDrawListener ) {
323 if( onDrawListener.run(this, gl, renderer) ) {
324 onDrawListener = null;
325 }
326 }
327 }
328
329 /**
330 * Validates the shape's underlying {@link GLRegion}.
331 * <p>
332 * If the region is dirty, it gets {@link GLRegion#clear(GL2ES2) cleared} and is reused.
333 * </p>
334 * @param gl current {@link GL2ES2} object
335 * @see #validate(GLProfile)
336 */
337 public final Shape validate(final GL2ES2 gl) {
338 synchronized ( dirtySync ) {
339 if( isShapeDirty() ) {
340 box.reset();
341 }
342 validateImpl(gl, gl.getGLProfile());
343 dirty.set(0);
344 }
345 return this;
346 }
347
348 /**
349 * Validates the shape's underlying {@link GLRegion} w/o a current {@link GL2ES2} object
350 * <p>
351 * If the region is dirty a new region is created
352 * and the old one gets pushed to a dirty-list to get disposed when a GL context is available.
353 * </p>
354 * @see #validate(GL2ES2)
355 */
356 public final Shape validate(final GLProfile glp) {
357 synchronized ( dirtySync ) {
358 if( isShapeDirty() ) {
359 box.reset();
360 }
361 validateImpl(null, glp);
362 dirty.set(0);
363 }
364 return this;
365 }
366
367 /**
368 * Validate the shape via {@link #validate(GL2ES2)} if {@code gl} is not null,
369 * otherwise uses {@link #validate(GLProfile)}.
370 * @see #validate(GL2ES2)
371 * @see #validate(GLProfile)
372 */
373 public final Shape validate(final GL2ES2 gl, final GLProfile glp) {
374 if( null != gl ) {
375 return validate(gl);
376 } else {
377 return validate(glp);
378 }
379 }
380
381 /**
382 * Applies the internal {@link Matrix4f} to the given {@link PMVMatrix4f#getMv() modelview matrix},
383 * i.e. {@code pmv.mulMv( getMat() )}.
384 * <p>
385 * Calls {@link #updateMat()} if dirty.
386 * </p>
387 * In case {@link #isMatIdentity()} is {@code true}, implementation is a no-operation.
388 * </p>
389 * @param pmv the matrix
390 * @see #isMatIdentity()
391 * @see #updateMat()
392 * @see #getMat()
393 * @see PMVMatrix4f#mulMv(Matrix4f)
394 */
395 void applyMatToMv(PMVMat4f& pmvMat) noexcept {
396 if( iMatDirty ) {
397 updateMat();
398 }
399 if( !iMatIdent ) {
400 pmvMat.mulMv(iMat);
401 }
402 }
403
404 private:
405 void updateMat() noexcept {
406 bool hasPos = !m_position.is_zero();
407 bool hasScale = m_scale != Vec3f::one;
408 bool hasRotate = !m_rotation.isIdentity();
409 bool hasRotPivot = false; // null != rotPivot;
410 const Vec3f& ctr = m_outlines.bounds().center();
411 bool sameScaleRotatePivot = hasScale && hasRotate && ( !hasRotPivot || m_rotPivot == ctr );
412
413 if( sameScaleRotatePivot ) {
414 iMatIdent = false;
415 iMat.setToTranslation(m_position); // identity + translate, scaled
416 // Scale shape from its center position and rotate around its center
417 iMat.translate(Vec3f(ctr).mul(m_scale)); // add-back center, scaled
418 iMat.rotate(m_rotation);
419 iMat.scale(m_scale);
420 iMat.translate(-ctr); // move to center
421 } else if( hasRotate || hasScale ) {
422 iMatIdent = false;
423 iMat.setToTranslation(m_position); // identity + translate, scaled
424 if( hasRotate ) {
425 if( hasRotPivot ) {
426 // Rotate shape around its scaled pivot
427 iMat.translate(Vec3f(m_rotPivot).mul(m_scale)); // pivot back from rot-pivot, scaled
428 iMat.rotate(m_rotation);
429 iMat.translate(Vec3f(-m_rotPivot).mul(m_scale)); // pivot to rot-pivot, scaled
430 } else {
431 // Rotate shape around its scaled center
432 iMat.translate(Vec3f(ctr).mul(m_scale)); // pivot back from center-pivot, scaled
433 iMat.rotate(m_rotation);
434 iMat.translate(Vec3f(-ctr).mul(m_scale)); // pivot to center-pivot, scaled
435 }
436 }
437 if( hasScale ) {
438 // Scale shape from its center position
439 iMat.translate(Vec3f(ctr).mul(m_scale)); // add-back center, scaled
440 iMat.scale(m_scale);
441 iMat.translate(Vec3f(-ctr).mul(m_scale)); // move to center
442 }
443 } else if( hasPos ) {
444 iMatIdent = false;
445 iMat.setToTranslation(m_position); // identity + translate, scaled
446
447 } else {
448 iMatIdent = true;
449 iMat.loadIdentity();
450 }
451 iMatDirty = false;
452 }
453
454 };
455
456#if 0
457 class ShapeMyPointerListener : public PointerListener {
458 private:
459 GearsES2& m_parent;
460 jau::math::Vec2i preWinPos;
461 jau::math::Vec3f startPos;
462 GearsObjectES2* m_picked = nullptr;
463 bool m_dragInit = true;
464
465 bool mapWinToObj(const GearsObjectES2& shape, const jau::math::Vec2i& winPos, jau::math::Vec3f& viewPos) noexcept {
466 // OK global: m_parent.m_pmvMatrix, m_parent.m_viewport
467 const jau::math::Vec3f& ctr = shape.objBounds().center();
468 if( m_parent.pmvMatrix().mapObjToWin(ctr, m_parent.viewport(), viewPos) ) {
469 const float winZ = viewPos.z;
470 return m_parent.pmvMatrix().mapWinToObj((float)winPos.x, (float)winPos.y, winZ, m_parent.viewport(), viewPos);
471 }
472 return false;
473 }
474 bool mapWinToObjRay(const jau::math::Vec2i& pos, jau::math::Ray3f& ray, const Mat4f& mPmvi) noexcept {
475 // OK global: m_parent.m_pmvMatrix, m_parent.m_viewport
476 constexpr float winZ0 = 0.0f;
477 constexpr float winZ1 = 0.3f;
478 return Mat4f::mapWinToAnyRay((float)pos.x, (float)pos.y, winZ0, winZ1, mPmvi, m_parent.viewport(), ray);
479 }
480
481 bool pick(const PointerEvent& e, const WindowRef&, GearsObjectES2& shape) noexcept {
482 // While being processed fast w/o matrix traversal of shapes,
483 // we still need to use the cached PMvi matrix for win->obj ray for accuracy.
484 // A win->view ray fails in certain angles in edge cases!
485 jau::math::Vec3f objPos;
486 jau::math::Ray3f objRay;
487 const jau::math::Vec2i& winPos = e.position();
488 if( !mapWinToObjRay(winPos, objRay, shape.matPMvi()) ) {
489 return false;
490 }
491 const jau::math::geom::AABBox3f& objBox = shape.objBounds();
492
493 if( !objBox.intersectsRay(objRay) ) {
494 return false;
495 }
496 if( !objBox.getRayIntersection(objPos, objRay, std::numeric_limits<float>::epsilon(), /*assumeIntersection=*/true) ) {
497 printf("obj getRayIntersection failed\n");
498 return false;
499 }
500 preWinPos = winPos;
501 printf("XXX pick: mouse %s -> %s\n", winPos.toString().c_str(), objPos.toString().c_str());
502 printf("XXX pick: %s\n", shape.toString().c_str());
503 return true;
504 }
505
506 bool navigate(const PointerEvent& e, const WindowRef& win, GearsObjectES2& shape) noexcept {
507 jau::math::Vec3f objPos;
508 const jau::math::Vec2i& winPos = e.position();
509 if( !mapWinToObj(shape, winPos, objPos) ) {
510 return false;
511 }
512 if( e.isControlDown() ) {
513 if( m_dragInit ) {
514 m_dragInit = false;
515 startPos = objPos;
516 } else {
518 jau::math::Vec3f diffPos = ( objPos - startPos ).mul(flip);
519 m_parent.pan() += diffPos;
520 }
521 } else {
522 const jau::math::Vec2i& sdim = win->surfaceSize();
523 const float thetaY = 360.0f * ((float)(winPos.x - preWinPos.x) / (float)sdim.x);
524 const float thetaX = 360.0f * ((float)(preWinPos.y - winPos.y) / (float)sdim.y);
525 m_parent.rotEuler().x += jau::adeg_to_rad(thetaX);
526 m_parent.rotEuler().y += jau::adeg_to_rad(thetaY);
527 m_dragInit = true;
528 }
529 preWinPos = winPos;
530 // printf("XXX navi: mouse %s -> %s\n", winPos.toString().c_str(), objPos.toString().c_str());
531 return true;
532 }
533
534 PointerShapeAction pickAction, navigateAction;
535
536 public:
537 MyPointerListener(GearsES2& p): m_parent(p) {
538 pickAction = jau::bind_member(this, &MyPointerListener::pick);
539 navigateAction = jau::bind_member(this, &MyPointerListener::navigate);
540 }
541 void pointerPressed(PointerEvent& e) override {
542 if( e.pointerCount() == 1 ) {
543 WindowRef win = e.source().lock();
544 if( !win ) {
545 return;
546 }
547 GearsObjectES2* new_pick = m_parent.findPick(pickAction, e, win); // no matrix traversal
548 if( m_picked ) {
549 m_picked->picked() = false;
550 }
551 m_picked = new_pick;
552 if( m_picked ) {
553 m_picked->picked() = true;
554 }
555 }
556 }
557 void pointerDragged(PointerEvent& e) override {
558 if( m_picked ) {
559 WindowRef win = e.source().lock();
560 if( !win ) {
561 return;
562 }
563 if( !m_parent.dispatchForShape(*m_picked, navigateAction, e, win) ) { // matrix traversal
564 if( m_picked ) {
565 m_picked->picked() = false;
566 }
567 m_picked = nullptr;
568 printf("XXX shape: lost\n");
569 }
570 }
571 }
572 void pointerWheelMoved(PointerEvent& e) override {
573 const jau::math::Vec3f& rot = e.rotation();
574 if( e.isControlDown() ) {
575 // alternative zoom
576 float incr = e.isShiftDown() ? rot.x : rot.y * 0.5f;
577 m_parent.pan().z += incr;
578 } else {
579 // panning
580 m_parent.pan().x -= rot.x; // positive -> left
581 m_parent.pan().y += rot.y; // positive -> up
582 }
583 }
584 void pointerReleased(PointerEvent&) override {
585 if( m_picked ) {
586 m_picked->picked() = false;
587 printf("XXX shape: released\n");
588 }
589 m_picked = nullptr;
590 m_dragInit = true;
591 }
592 };
593 typedef std::shared_ptr<MyPointerListener> MyPointerListenerRef;
594
595#endif
596
597 /**@}*/
598
599} // namespace gamp::graph
600
601#endif /* JAU_GAMP_GRAPH_UI_SHAPE_HPP_ */
jau::function< bool(const PointerEvent &e, const WindowRef &win, GearsObjectES2 &shape)> PointerShapeAction
Definition GearsES2.hpp:49
constexpr Vec3f & pan() noexcept
Definition GearsES2.hpp:428
GearsObjectES2 * findPick(const PointerShapeAction &action, const PointerEvent &e, const WindowRef &win)
Fast loop through all shapes using PointerShapeAction w/o matrix traversal using view-coordinates.
Definition GearsES2.hpp:611
constexpr jau::math::Vec3f & rotEuler() noexcept
Definition GearsES2.hpp:429
constexpr const jau::math::Recti & viewport() const noexcept
Definition GearsES2.hpp:427
bool dispatchForShape(GearsObjectES2 &shape, const PointerShapeAction &action, const PointerEvent &e, const WindowRef &win)
Dispatch PointerShapeAction to given shape w/ matrix traversal.
Definition GearsES2.hpp:631
PMVMat4f & pmvMatrix() noexcept
Definition GearsES2.hpp:425
bool & picked() noexcept
Definition GearsES2.hpp:367
A Generic shape objects which is defined by a list of Outlines.
const AABBox3f & bounds() const noexcept
Container interface of UI Shapes.
Definition Container.hpp:58
jau::math::geom::AABBox3f box
Definition Shape.hpp:141
virtual bool hasColorChannel() const noexcept
Returns true if implementation uses an extra color channel or texture which will be modulated with th...
constexpr void setColor(const Vec4f &c) noexcept
Definition Shape.hpp:247
virtual void validateImpl(const render::gl::GL &gl, const render::gl::GLProfile &glp) noexcept
virtual void destroyImpl0(const render::gl::GL &gl, RegionRenderer &renderer)
Custom destroy(GL2ES2, RegionRenderer) task, called 1st.
jau::function< void(ShapeRef &s, const Vec3f &pos, const PointerEvent &e)> PointerEventCallback
Shape pointer listener, e.g.
Definition Shape.hpp:114
constexpr const Vec3f & position() const noexcept
Definition Shape.hpp:228
virtual void clearImpl0(const render::gl::GL &gl, RegionRenderer &renderer)
Custom clear(GL2ES2, RegionRenderer) task, called 1st.
static constexpr Vec4f toggleOnRGBAModulate
Default toggle color-factor (darker), modulates base-color.
Definition Shape.hpp:148
jau::function< bool(ShapeRef &s, PMVMat4f &pmv)> Visitor2Func
Visitor2 method.
Definition Shape.hpp:97
Shape & setPressed(bool b) noexcept
Definition Shape.hpp:253
constexpr Quat4f & rotation() noexcept
Definition Shape.hpp:235
static constexpr Vec4f rgbaColor
Default base-color w/o color channel, will be modulated w/ pressed- and toggle color.
Definition Shape.hpp:144
constexpr const Quat4f & rotation() const noexcept
Definition Shape.hpp:234
constexpr const Vec3f & scale() const noexcept
Definition Shape.hpp:240
static constexpr const uint32_t DIRTY_STATE
Definition Shape.hpp:138
virtual void drawToSelectImpl0(const render::gl::GL &gl, RegionRenderer &renderer)
Actual draw implementation, called by drawToSelect(GL2ES2, RegionRenderer).
final Shape validate(final GLProfile glp)
Validates the shape's underlying GLRegion w/o a current GL2ES2 object.
Definition Shape.hpp:356
constexpr Vec3f & rotationPivot() noexcept
Definition Shape.hpp:238
constexpr const float & zOffset() const noexcept
Definition Shape.hpp:231
bool isPressed() const noexcept
Definition Shape.hpp:258
bool isToggleable() const noexcept
Returns true if this shape is toggable, i.e.
Definition Shape.hpp:275
static constexpr Vec4f toggleOffRGBAModulate
Default toggle color-factor (original), modulates base-color.
Definition Shape.hpp:150
static constexpr Vec4f cWhite
Definition Shape.hpp:153
void draw(render::gl::GL &gl, RegionRenderer &renderer) noexcept
Renders the shape.
Definition Shape.hpp:285
virtual Container * asContainer() const noexcept
Definition Shape.hpp:226
static constexpr const uint32_t DIRTY_SHAPE
Shape draw listener action returning a boolean value
Definition Shape.hpp:137
constexpr const Vec4f & color() const noexcept
Definition Shape.hpp:246
virtual void drawImpl0(const render::gl::GL &gl, RegionRenderer &renderer, const Vec4f &rgba) noexcept
Actual draw implementation, called by draw(GL2ES2, RegionRenderer).
final Shape validate(final GL2ES2 gl, final GLProfile glp)
Validate the shape via validate(GL2ES2) if gl is not null, otherwise uses validate(GLProfile).
Definition Shape.hpp:373
jau::function< void(ShapeRef &s, const Vec3f &origin, const Vec3f &dest, const PointerEvent &e)> MoveEventCallback
Shape move listener
Definition Shape.hpp:106
jau::function< bool(ShapeRef &s)> Visitor1Func
Visitor1 method.
Definition Shape.hpp:89
constexpr const OutlineShape & outlines() const noexcept
Definition Shape.hpp:243
constexpr OutlineShape & outlines() noexcept
Definition Shape.hpp:244
constexpr Vec3f & scale() noexcept
Definition Shape.hpp:241
constexpr Vec3f & position() noexcept
Definition Shape.hpp:229
static constexpr Vec4f pressedRGBAModulate
Default pressed color-factor (darker and slightly transparent), modulates base-color.
Definition Shape.hpp:146
Shape & setToggleable(bool toggleable) noexcept
Set this shape toggleable, default is off.
Definition Shape.hpp:265
constexpr float & zOffset() noexcept
Definition Shape.hpp:232
final Shape validate(final GL2ES2 gl)
Validates the shape's underlying GLRegion.
Definition Shape.hpp:337
constexpr const Vec3f & rotationPivot() const noexcept
Definition Shape.hpp:237
jau::function< void(ShapeRef &s)> ShapeEventCallback
General Shape listener action.
Definition Shape.hpp:119
static constexpr Vec4f activeRGBAModulate
Default active color-factor (dark), modulates base-color.
Definition Shape.hpp:152
void applyMatToMv(PMVMat4f &pmvMat) noexcept
Applies the internal Matrix4f to the given modelview matrix, i.e.
Definition Shape.hpp:395
Specifies the OpenGL profile.
Definition GLContext.hpp:42
constexpr bool isShiftDown() const noexcept
Returns true if modifier() contains InputModifier::shift.
Definition Event.hpp:285
constexpr bool isControlDown() const noexcept
Returns true if modifier() contains InputModifier::ctrl.
Definition Event.hpp:277
Pointer event of type PointerType.
constexpr size_t pointerCount() const noexcept
See details for multiple-pointer events.
constexpr const jau::math::Vec3f & rotation() const noexcept
Returns a 3-component float array filled with the values of the rotational axis in the following orde...
Listener for PointerEvent.
constexpr const WindowWeakPtr & source() const noexcept
Definition Event.hpp:85
Implementation of a Copy-On-Write (CoW) using jau::darray as the underlying storage,...
Class template jau::function is a general-purpose static-polymorphic function wrapper.
static bool mapWinToAnyRay(const value_type winx, const value_type winy, const value_type winz0, const value_type winz1, const Matrix4 &invAny, const Recti &viewport, Ray3 &ray) noexcept
Definition mat4f.hpp:1914
constexpr Matrix4 & scale(const value_type x, const value_type y, const value_type z) noexcept
Scale this matrix, i.e.
Definition mat4f.hpp:1466
constexpr_cxx26 Matrix4 & rotate(const value_type ang_rad, const value_type x, const value_type y, const value_type z) noexcept
Rotate this matrix about give axis and angle in radians, i.e.
Definition mat4f.hpp:1413
constexpr Matrix4 & translate(const value_type x, const value_type y, const value_type z) noexcept
Translate this matrix, i.e.
Definition mat4f.hpp:1444
constexpr Matrix4 & setToTranslation(const value_type x, const value_type y, const value_type z) noexcept
Set this matrix to translation.
Definition mat4f.hpp:912
constexpr bool isIdentity() const noexcept
Returns true if this quaternion has identity.
value_type y
Definition vec2i.hpp:64
std::string toString() const noexcept
Definition vec2i.hpp:215
value_type x
Definition vec2i.hpp:63
constexpr bool is_zero() const noexcept
Definition vec3f.hpp:238
value_type z
Definition vec3f.hpp:68
value_type x
Definition vec3f.hpp:66
std::string toString() const noexcept
Definition vec3f.hpp:236
value_type y
Definition vec3f.hpp:67
static constexpr const value_type one
Definition vec3f.hpp:64
constexpr Vector4F & mul(const Vector4F &s) noexcept
this = this * {s.x, s.y, s.z}, component wise.
Definition vec4f.hpp:154
constexpr Vector4F & set(const Vec3f &o, const value_type w_) noexcept
TODO constexpr std::strong_ordering operator<=>(const vec4f_t& rhs) const noexcept { return ....
Definition vec4f.hpp:135
Axis Aligned Bounding Box.
Definition aabbox3f.hpp:43
constexpr bool intersectsRay(const Ray3f &r) const noexcept
Check if Ray intersects this bounding box.
Definition aabbox3f.hpp:533
bool getRayIntersection(Vec3f &result, const Ray3f &ray, const float epsilon, const bool assumeIntersection) const noexcept
Return intersection of a Ray with this bounding box, or false if none exist.
Definition aabbox3f.hpp:578
constexpr const Point3f & center() const noexcept
Returns computed center of this aabbox3f of low() and high().
Definition aabbox3f.hpp:105
bool mapWinToObj(const float winx, const float winy, const float winz, const Recti &viewport, Vec3 &objPos) noexcept
Map window coordinates to object coordinates.
Definition pmvmat4.hpp:968
bool mapObjToWin(const Vec3 &objPos, const Recti &viewport, Vec3 &winPos) const noexcept
Map object coordinates to window coordinates.
Definition pmvmat4.hpp:921
ordered_atomic< uint32_t, std::memory_order_relaxed > relaxed_atomic_uint32
Relaxed non-SC atomic integral scalar uint32_t.
#define JAU_MAKE_BITFIELD_ENUM_STRING(type,...)
constexpr bool is_set(const E mask, const E bits) noexcept
constexpr E & write(E &store, const E bits, bool set) noexcept
If set==true, sets the bits in store, i.e.
constexpr T adeg_to_rad(const T arc_degree) noexcept
Converts arc-degree to radians.
jau::function< R(A...)> bind_member(C1 *base, R(C0::*mfunc)(A...)) noexcept
Bind given class instance and non-void member function to an anonymous function using func_member_tar...
std::shared_ptr< Shape > ShapeRef
Definition Container.hpp:48
std::shared_ptr< Window > WindowRef
Definition Event.hpp:36
Matrix4< float > Mat4f
Definition mat4f.hpp:1968
Vector2I< int > Vec2i
Definition vec2i.hpp:321
Ray3F< float > Ray3f
Definition vec3f.hpp:486
Vector4F< float > Vec4f
Definition vec4f.hpp:360
constexpr jau::math::Vec3f getEulerAngleOrientation(const jau::math::Vec3f &eulerRotation) noexcept
Returns an orientation vector for given eurler X/Y/Z angles in radians.
Quaternion< float > Quat4f
Vector3F< float > Vec3f
Definition vec3f.hpp:422
PMVMatrix4< float > PMVMat4f
Definition pmvmat4.hpp:1463
int printf(const char *format,...)
Operating Systems predefined macros.