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_DAG_SHAPE_HPP_
12#define JAU_GAMP_DAG_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
31#include <gamp/GampTypes.hpp>
32#include <gamp/Gamp.hpp>
34#include <mutex>
35#include <vector>
36
37namespace gamp::dag {
38
39 using namespace jau::math;
40 using namespace jau::math::util;
41 using namespace jau::math::geom;
42
43 using namespace gamp::wt;
44 using namespace gamp::wt::event;
45
46 using namespace jau::int_literals;
47
48 using namespace jau::enums;
49
50 /** \addtogroup Gamp_DAG
51 *
52 * @{
53 */
54
55 namespace impl {
56 enum class IOState : uint32_t {
57 none = 0,
58 visible = 1_u32 << 0,
59 interactive = 1_u32 << 1,
60 activable = 1_u32 << 2,
61 toggleable = 1_u32 << 3,
62 draggable = 1_u32 << 4,
63 resizable = 1_u32 << 5,
64 resize_fixed_ratio = 1_u32 << 6,
65 active = 1_u32 << 7,
66 discarded = 1_u32 << 25,
67 down = 1_u32 << 26,
68 toggle = 1_u32 << 27,
69 drag_first = 1_u32 << 28,
70 in_move = 1_u32 << 29,
71 in_resize_br = 1_u32 << 30,
72 in_resize_bl = 1_u32 << 31
73 };
77 }
78
79 class Shape;
80 typedef std::shared_ptr<Shape> ShapeRef;
81 typedef std::vector<ShapeRef> ShapeList;
82
84 };
85
86 class Shape {
87 public:
88 /**
89 * Visitor1 method
90 * @param s the {@link Shape} to process
91 * @return true to signal operation complete and to stop traversal, otherwise false
92 */
93 typedef jau::function<bool(Shape& s)> Visitor1Func;
94
95 /**
96 * Visitor2 method
97 * @param s the {@link Shape} to process
98 * @param pmv the {@link PMVMatrix4f} setup from the {@link Scene} down to the {@link Shape}
99 * @return true to signal operation complete and to stop traversal, otherwise false
100 */
101 typedef jau::function<bool(Shape& s, PMVMat4f& pmv)> Visitor2Func;
102
103 /**
104 * {@link Shape} move listener
105 * @param s the moved shape
106 * @param origin original position, relative object coordinates to the associated {@link Shape}
107 * @param dest new position, relative object coordinates to the associated {@link Shape}
108 * @param e original Newt {@link MouseEvent}
109 */
110 typedef jau::function<void(Shape& s, const Vec3f& origin, const Vec3f& dest, const PointerEvent& e)> MoveEventCallback;
111
112 /**
113 * {@link Shape} pointer listener, e.g. for {@link Shape#onClicked(PointerListener)}
114 * @param s the associated {@link Shape} for this event
115 * @param pos relative object coordinates to the associated {@link Shape}
116 * @param e original Newt {@link MouseEvent}
117 */
118 typedef jau::function<void(Shape& s, const Vec3f& pos, const PointerEvent& e)> PointerEventCallback;
119
120 /**
121 * General {@link Shape} listener action
122 */
124
125 /**
126 * {@link Shape} draw listener action returning a boolean value
127 * <p>
128 * If {@link #run(Shape, GL2ES2, RenderState)} returns {@code true},
129 * the listener will be removed at {@link Shape#draw(GL2ES2, RenderState)}
130 * otherwise kept calling.
131 * </p>
132 *
133 * Return {@code true} to remove this {@link DrawListener} at {@link Shape#draw(GL2ES2, RenderState)},
134 * otherwise it is being kept and called.
135 * @param shape The shape
136 * @param gl the current {@link GL2ES2} object
137 * @param rs the {@link RenderState}
138 */
140
141 constexpr static const uint32_t DIRTY_SHAPE = 1_u32 << 0 ;
142 constexpr static const uint32_t DIRTY_STATE = 1_u32 << 1 ;
143
144 protected:
146
147 private:
148 // volatile Group parent = null;
149
150 Vec3f m_position;
151 Quat4f m_rotation;
152 Vec3f m_rotPivot;
153 Vec3f m_scale = Vec3f(1, 1, 1);
154 float m_zOffset;
155
156 Mat4f m_iMat;
157 Mat4f m_tmpMat;
158 bool m_iMatIdent = true;
159 bool m_iMatDirty = false;
160
162 std::recursive_mutex m_dirtySync;
163
166
167 std::vector<KeyListenerRef> m_keyListener;
168 std::vector<PointerListenerRef> m_pointerListener;
169
170 DrawCallback m_onDrawCallback;
171
172 protected:
173 //
174 //
175 //
176
177 virtual void validateImpl(render::gl::GL& gl) noexcept;
178 virtual void validateImpl(const render::gl::GLProfile& glp) noexcept;
179
180 /**
181 * Actual draw implementation, called by {@link #draw(GL2ES2, RenderState)}
182 * @param gl
183 * @param rs
184 * @param rgba
185 */
186 virtual void drawImpl0(render::gl::GL& gl, RenderState& rs) noexcept;
187
188 /** Custom {@link #clear(GL2ES2, RenderState)} task, called 1st. */
189 virtual void clearImpl0(render::gl::GL& gl, RenderState& rs);
190
191 /** Custom {@link #destroy(GL2ES2, RenderState)} task, called 1st. */
193
194 public:
195 Shape() = default;
196
197 /**
198 * Set a user one-shot initializer callback or custom {@link #draw(GL2ES2, RegionRenderer)} hook.
199 * <p>
200 * {@link #run(Shape, GL2ES2, RegionRenderer)} is called at {@link Shape#draw(GL2ES2, RegionRenderer)}
201 * and if returning {@code true}, the listener will be removed.
202 * Otherwise kept calling.
203 * </p>
204 * <p>
205 * This instrument allows the user either to be signaled when initialization
206 * of this {@link Shape} is completed, or just too hook-up custom {@link #draw(GL2ES2, RegionRenderer)}
207 * actions.
208 * </p>
209 * @param l callback, which shall return true to be removed, i.e. user initialization is done.
210 */
211 void onDrawOneShot(DrawCallback l) { m_onDrawCallback = std::move(l); }
212
213 /**
214 * Returns true if implementation uses an extra color channel or texture
215 * which will be modulated with the passed rgba color {@link #drawImpl0(GL2ES2, RenderState, float[])}.
216 *
217 * Otherwise the base color will be modulated and passed to {@link #drawImpl0(GL2ES2, RenderState, float[])}.
218 */
219 virtual bool hasColorChannel() const noexcept;
220
221 constexpr const Vec3f& position() const noexcept { return m_position; }
222 constexpr Vec3f& position() noexcept { m_iMatDirty=true; return m_position; }
223
224 constexpr const float& zOffset() const noexcept { return m_zOffset; }
225 constexpr float& zOffset() noexcept { m_iMatDirty=true; return m_zOffset; }
226
227 constexpr const Quat4f& rotation() const noexcept { return m_rotation; }
228 constexpr Quat4f& rotation() noexcept { m_iMatDirty=true; return m_rotation; }
229
230 constexpr const Vec3f& rotationPivot() const noexcept { return m_rotPivot; }
231 constexpr Vec3f& rotationPivot() noexcept { m_iMatDirty=true; return m_rotPivot; }
232
233 constexpr const Vec3f& scale() const noexcept { return m_scale; }
234 constexpr Vec3f& scale() noexcept { m_iMatDirty=true; return m_scale; }
235
236 /**
237 * Marks the shape dirty, causing next {@link #draw(GL2ES2, RegionRenderer) draw()}
238 * to recreate the Graph shape and reset the region.
239 */
240 void markShapeDirty() noexcept {
241 m_dirty.fetch_or(DIRTY_SHAPE);
242 }
243
244 /**
245 * Marks the rendering state dirty, causing next {@link #draw(GL2ES2, RegionRenderer) draw()}
246 * to notify the Graph region to reselect shader and repaint potentially used FBOs.
247 */
248 void markStateDirty() noexcept {
249 m_dirty.fetch_or(DIRTY_STATE);
250 }
251
252 protected:
253
254 /** Returns the shape's dirty state, see {@link #markShapeDirty()}. */
255 bool isShapeDirty() const noexcept {
256 return 0 != ( m_dirty & DIRTY_SHAPE ) ;
257 }
258 /** Returns the rendering dirty state, see {@link #markStateDirty()}. */
259 bool isStateDirty() const noexcept {
260 return 0 != ( m_dirty & DIRTY_STATE ) ;
261 }
262
263 std::string_view getDirtyString() const noexcept {
264 if( isShapeDirty() && isShapeDirty() ) {
265 return "dirty[shape, state]";
266 } else if( isShapeDirty() ) {
267 return "dirty[shape]";
268 } else if( isStateDirty() ) {
269 return "dirty[state]";
270 } else {
271 return "clean";
272 }
273 }
274
275 public:
276 //
277 // Input
278 //
279
280 Shape& setPressed(bool b) noexcept {
281 write(m_ioState, impl::IOState::down, b);
283 return *this;
284 }
285 bool isPressed() const noexcept { return is_set(m_ioState, impl::IOState::down); }
286
287 /**
288 * Set this shape toggleable, default is off.
289 * @param toggleable
290 * @see #isInteractive()
291 */
292 Shape& setToggleable(bool toggleable) noexcept {
293 write(m_ioState, impl::IOState::toggleable, toggleable);
294 return *this;
295 }
296
297 /**
298 * Returns true if this shape is toggable,
299 * i.e. rendered w/ {@link #setToggleOnColorMod(float, float, float, float)} or {@link #setToggleOffColorMod(float, float, float, float)}.
300 * @see #isInteractive()
301 */
302 bool isToggleable() const noexcept { return is_set(m_ioState, impl::IOState::toggleable); }
303
304 /**
305 * Renders the shape.
306 * <p>
307 * {@link #applyMatToMv(PMVMatrix4f)} is expected to be completed beforehand.
308 * </p>
309 * @param gl the current GL object
310 * @param renderer {@link RenderState} which might be used for Graph Curve Rendering, also source of {@link RenderState#getMatrix()} and {@link RenderState#getViewport()}.
311 */
312 void draw(render::gl::GL& gl, RenderState& rs) noexcept {
313 {
314 const std::lock_guard<std::recursive_mutex> lock(m_dirtySync);
315 validate(gl);
316 drawImpl0(gl, rs);
317 }
318 if( m_onDrawCallback) {
319 if( m_onDrawCallback(*this, gl, rs) ) {
320 m_onDrawCallback = nullptr;
321 }
322 }
323 }
324
325 /**
326 * Validates the shape's underlying {@link GLRegion}.
327 * <p>
328 * If the region is dirty, it gets {@link GLRegion#clear(GL2ES2) cleared} and is reused.
329 * </p>
330 * @param gl current {@link GL2ES2} object
331 * @see #validate(GLProfile)
332 */
334 {
335 const std::lock_guard<std::recursive_mutex> lock(m_dirtySync);
336 if( isShapeDirty() ) {
337 m_box.reset();
338 }
339 validateImpl(gl);
340 m_dirty = 0;
341 }
342 return *this;
343 }
344
345 /**
346 * Validates the shape's underlying {@link GLRegion} w/o a current {@link GL2ES2} object
347 * <p>
348 * If the region is dirty a new region is created
349 * and the old one gets pushed to a dirty-list to get disposed when a GL context is available.
350 * </p>
351 * @see #validate(GL2ES2)
352 */
354 {
355 const std::lock_guard<std::recursive_mutex> lock(m_dirtySync);
356 if( isShapeDirty() ) {
357 m_box.reset();
358 }
359 validateImpl(glp);
360 m_dirty = 0;
361 }
362 return *this;
363 }
364
365 /**
366 * Validate the shape via {@link #validate(GL2ES2)} if {@code gl} is not null,
367 * otherwise uses {@link #validate(GLProfile)}.
368 * @see #validate(GL2ES2)
369 * @see #validate(GLProfile)
370 */
371 public final Shape validate(final GL2ES2 gl, final GLProfile glp) {
372 if( null != gl ) {
373 return validate(gl);
374 } else {
375 return validate(glp);
376 }
377 }
378
379 /**
380 * Applies the internal {@link Matrix4f} to the given {@link PMVMatrix4f#getMv() modelview matrix},
381 * i.e. {@code pmv.mulMv( getMat() )}.
382 * <p>
383 * Calls {@link #updateMat()} if dirty.
384 * </p>
385 * In case {@link #isMatIdentity()} is {@code true}, implementation is a no-operation.
386 * </p>
387 * @param pmv the matrix
388 * @see #isMatIdentity()
389 * @see #updateMat()
390 * @see #getMat()
391 * @see PMVMatrix4f#mulMv(Matrix4f)
392 */
393 void applyMatToMv(PMVMat4f& pmvMat) noexcept {
394 if( iMatDirty ) {
395 updateMat();
396 }
397 if( !iMatIdent ) {
398 pmvMat.mulMv(iMat);
399 }
400 }
401
402 private:
403 void updateMat() noexcept {
404 bool hasPos = !m_position.is_zero();
405 bool hasScale = m_scale != Vec3f::one;
406 bool hasRotate = !m_rotation.isIdentity();
407 bool hasRotPivot = false; // null != rotPivot;
408 const Vec3f& ctr = m_outlines.bounds().center();
409 bool sameScaleRotatePivot = hasScale && hasRotate && ( !hasRotPivot || m_rotPivot == ctr );
410
411 if( sameScaleRotatePivot ) {
412 iMatIdent = false;
413 iMat.setToTranslation(m_position); // identity + translate, scaled
414 // Scale shape from its center position and rotate around its center
415 iMat.translate(Vec3f(ctr).mul(m_scale)); // add-back center, scaled
416 iMat.rotate(m_rotation);
417 iMat.scale(m_scale);
418 iMat.translate(-ctr); // move to center
419 } else if( hasRotate || hasScale ) {
420 iMatIdent = false;
421 iMat.setToTranslation(m_position); // identity + translate, scaled
422 if( hasRotate ) {
423 if( hasRotPivot ) {
424 // Rotate shape around its scaled pivot
425 iMat.translate(Vec3f(m_rotPivot).mul(m_scale)); // pivot back from rot-pivot, scaled
426 iMat.rotate(m_rotation);
427 iMat.translate(Vec3f(-m_rotPivot).mul(m_scale)); // pivot to rot-pivot, scaled
428 } else {
429 // Rotate shape around its scaled center
430 iMat.translate(Vec3f(ctr).mul(m_scale)); // pivot back from center-pivot, scaled
431 iMat.rotate(m_rotation);
432 iMat.translate(Vec3f(-ctr).mul(m_scale)); // pivot to center-pivot, scaled
433 }
434 }
435 if( hasScale ) {
436 // Scale shape from its center position
437 iMat.translate(Vec3f(ctr).mul(m_scale)); // add-back center, scaled
438 iMat.scale(m_scale);
439 iMat.translate(Vec3f(-ctr).mul(m_scale)); // move to center
440 }
441 } else if( hasPos ) {
442 iMatIdent = false;
443 iMat.setToTranslation(m_position); // identity + translate, scaled
444
445 } else {
446 iMatIdent = true;
447 iMat.loadIdentity();
448 }
449 iMatDirty = false;
450 }
451
452 };
453
454#if 0
455 class ShapeMyPointerListener : public PointerListener {
456 private:
457 GearsES2& m_parent;
458 jau::math::Vec2i preWinPos;
459 jau::math::Vec3f startPos;
460 GearsObjectES2* m_picked = nullptr;
461 bool m_dragInit = true;
462
463 bool mapWinToObj(const GearsObjectES2& shape, const jau::math::Vec2i& winPos, jau::math::Vec3f& viewPos) noexcept {
464 // OK global: m_parent.m_pmvMatrix, m_parent.m_viewport
465 const jau::math::Vec3f& ctr = shape.objBounds().center();
466 if( m_parent.pmvMatrix().mapObjToWin(ctr, m_parent.viewport(), viewPos) ) {
467 const float winZ = viewPos.z;
468 return m_parent.pmvMatrix().mapWinToObj((float)winPos.x, (float)winPos.y, winZ, m_parent.viewport(), viewPos);
469 }
470 return false;
471 }
472 bool mapWinToObjRay(const jau::math::Vec2i& pos, jau::math::Ray3f& ray, const Mat4f& mPmvi) noexcept {
473 // OK global: m_parent.m_pmvMatrix, m_parent.m_viewport
474 constexpr float winZ0 = 0.0f;
475 constexpr float winZ1 = 0.3f;
476 return Mat4f::mapWinToAnyRay((float)pos.x, (float)pos.y, winZ0, winZ1, mPmvi, m_parent.viewport(), ray);
477 }
478
479 bool pick(const PointerEvent& e, const WindowRef&, GearsObjectES2& shape) noexcept {
480 // While being processed fast w/o matrix traversal of shapes,
481 // we still need to use the cached PMvi matrix for win->obj ray for accuracy.
482 // A win->view ray fails in certain angles in edge cases!
483 jau::math::Vec3f objPos;
484 jau::math::Ray3f objRay;
485 const jau::math::Vec2i& winPos = e.position();
486 if( !mapWinToObjRay(winPos, objRay, shape.matPMvi()) ) {
487 return false;
488 }
489 const jau::math::geom::AABBox3f& objBox = shape.objBounds();
490
491 if( !objBox.intersectsRay(objRay) ) {
492 return false;
493 }
494 if( !objBox.getRayIntersection(objPos, objRay, std::numeric_limits<float>::epsilon(), /*assumeIntersection=*/true) ) {
495 printf("obj getRayIntersection failed\n");
496 return false;
497 }
498 preWinPos = winPos;
499 printf("XXX pick: mouse %s -> %s\n", winPos.toString().c_str(), objPos.toString().c_str());
500 printf("XXX pick: %s\n", shape.toString().c_str());
501 return true;
502 }
503
504 bool navigate(const PointerEvent& e, const WindowRef& win, GearsObjectES2& shape) noexcept {
505 jau::math::Vec3f objPos;
506 const jau::math::Vec2i& winPos = e.position();
507 if( !mapWinToObj(shape, winPos, objPos) ) {
508 return false;
509 }
510 if( e.isControlDown() ) {
511 if( m_dragInit ) {
512 m_dragInit = false;
513 startPos = objPos;
514 } else {
516 jau::math::Vec3f diffPos = ( objPos - startPos ).mul(flip);
517 m_parent.pan() += diffPos;
518 }
519 } else {
520 const jau::math::Vec2i& sdim = win->surfaceSize();
521 const float thetaY = 360.0f * ((float)(winPos.x - preWinPos.x) / (float)sdim.x);
522 const float thetaX = 360.0f * ((float)(preWinPos.y - winPos.y) / (float)sdim.y);
523 m_parent.rotEuler().x += jau::adeg_to_rad(thetaX);
524 m_parent.rotEuler().y += jau::adeg_to_rad(thetaY);
525 m_dragInit = true;
526 }
527 preWinPos = winPos;
528 // printf("XXX navi: mouse %s -> %s\n", winPos.toString().c_str(), objPos.toString().c_str());
529 return true;
530 }
531
532 PointerShapeAction pickAction, navigateAction;
533
534 public:
535 MyPointerListener(GearsES2& p): m_parent(p) {
536 pickAction = jau::bind_member(this, &MyPointerListener::pick);
537 navigateAction = jau::bind_member(this, &MyPointerListener::navigate);
538 }
539 void pointerPressed(PointerEvent& e) override {
540 if( e.pointerCount() == 1 ) {
541 WindowRef win = e.source().lock();
542 if( !win ) {
543 return;
544 }
545 GearsObjectES2* new_pick = m_parent.findPick(pickAction, e, win); // no matrix traversal
546 if( m_picked ) {
547 m_picked->picked() = false;
548 }
549 m_picked = new_pick;
550 if( m_picked ) {
551 m_picked->picked() = true;
552 }
553 }
554 }
555 void pointerDragged(PointerEvent& e) override {
556 if( m_picked ) {
557 WindowRef win = e.source().lock();
558 if( !win ) {
559 return;
560 }
561 if( !m_parent.dispatchForShape(*m_picked, navigateAction, e, win) ) { // matrix traversal
562 if( m_picked ) {
563 m_picked->picked() = false;
564 }
565 m_picked = nullptr;
566 printf("XXX shape: lost\n");
567 }
568 }
569 }
570 void pointerWheelMoved(PointerEvent& e) override {
571 const jau::math::Vec3f& rot = e.rotation();
572 if( e.isControlDown() ) {
573 // alternative zoom
574 float incr = e.isShiftDown() ? rot.x : rot.y * 0.5f;
575 m_parent.pan().z += incr;
576 } else {
577 // panning
578 m_parent.pan().x -= rot.x; // positive -> left
579 m_parent.pan().y += rot.y; // positive -> up
580 }
581 }
582 void pointerReleased(PointerEvent&) override {
583 if( m_picked ) {
584 m_picked->picked() = false;
585 printf("XXX shape: released\n");
586 }
587 m_picked = nullptr;
588 m_dragInit = true;
589 }
590 };
591 typedef std::shared_ptr<MyPointerListener> MyPointerListenerRef;
592
593#endif
594
595 /**@}*/
596
597} // namespace gamp::graph
598
599#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
Shape & validate(render::gl::GL &gl) noexcept
Validates the shape's underlying GLRegion.
Definition Shape.hpp:333
constexpr Vec3f & rotationPivot() noexcept
Definition Shape.hpp:231
constexpr float & zOffset() noexcept
Definition Shape.hpp:225
virtual void validateImpl(const render::gl::GLProfile &glp) noexcept
constexpr Vec3f & scale() noexcept
Definition Shape.hpp:234
jau::function< void(Shape &s, const Vec3f &origin, const Vec3f &dest, const PointerEvent &e)> MoveEventCallback
Shape move listener
Definition Shape.hpp:110
void draw(render::gl::GL &gl, RenderState &rs) noexcept
Renders the shape.
Definition Shape.hpp:312
bool isStateDirty() const noexcept
Returns the rendering dirty state, see markStateDirty().
Definition Shape.hpp:259
virtual void validateImpl(render::gl::GL &gl) noexcept
jau::function< bool(Shape &s)> Visitor1Func
Visitor1 method.
Definition Shape.hpp:93
jau::function< bool(Shape &s, render::gl::GL &gl, RenderState &rs)> DrawCallback
Shape draw listener action returning a boolean value
Definition Shape.hpp:139
jau::function< bool(Shape &s, PMVMat4f &pmv)> Visitor2Func
Visitor2 method.
Definition Shape.hpp:101
void onDrawOneShot(DrawCallback l)
Set a user one-shot initializer callback or custom draw(GL2ES2, RegionRenderer) hook.
Definition Shape.hpp:211
virtual void clearImpl0(render::gl::GL &gl, RenderState &rs)
Custom clear(GL2ES2, RenderState) task, called 1st.
constexpr Vec3f & position() noexcept
Definition Shape.hpp:222
bool isPressed() const noexcept
Definition Shape.hpp:285
virtual void drawImpl0(render::gl::GL &gl, RenderState &rs) noexcept
Actual draw implementation, called by draw(GL2ES2, RenderState).
Shape & setPressed(bool b) noexcept
Definition Shape.hpp:280
jau::function< void(Shape &s, const Vec3f &pos, const PointerEvent &e)> PointerEventCallback
Shape pointer listener, e.g.
Definition Shape.hpp:118
static constexpr const uint32_t DIRTY_STATE
Definition Shape.hpp:142
std::string_view getDirtyString() const noexcept
Definition Shape.hpp:263
constexpr const float & zOffset() const noexcept
Definition Shape.hpp:224
void applyMatToMv(PMVMat4f &pmvMat) noexcept
Applies the internal Matrix4f to the given modelview matrix, i.e.
Definition Shape.hpp:393
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:371
constexpr Quat4f & rotation() noexcept
Definition Shape.hpp:228
static constexpr const uint32_t DIRTY_SHAPE
Definition Shape.hpp:141
Shape & validate(render::gl::GLProfile &glp)
Validates the shape's underlying GLRegion w/o a current GL2ES2 object.
Definition Shape.hpp:353
jau::math::geom::AABBox3f m_box
Definition Shape.hpp:145
constexpr const Quat4f & rotation() const noexcept
Definition Shape.hpp:227
bool isToggleable() const noexcept
Returns true if this shape is toggable, i.e.
Definition Shape.hpp:302
constexpr const Vec3f & scale() const noexcept
Definition Shape.hpp:233
virtual bool hasColorChannel() const noexcept
Returns true if implementation uses an extra color channel or texture which will be modulated with th...
constexpr const Vec3f & position() const noexcept
Definition Shape.hpp:221
jau::function< void(Shape &s)> ShapeEventCallback
General Shape listener action.
Definition Shape.hpp:123
constexpr const Vec3f & rotationPivot() const noexcept
Definition Shape.hpp:230
virtual void destroyImpl0(render::gl::GL &gl, RenderState &rs)
Custom destroy(GL2ES2, RenderState) task, called 1st.
bool isShapeDirty() const noexcept
Returns the shape's dirty state, see markShapeDirty().
Definition Shape.hpp:255
void markShapeDirty() noexcept
Marks the shape dirty, causing next draw() to recreate the Graph shape and reset the region.
Definition Shape.hpp:240
void markStateDirty() noexcept
Marks the rendering state dirty, causing next draw() to notify the Graph region to reselect shader an...
Definition Shape.hpp:248
Shape & setToggleable(bool toggleable) noexcept
Set this shape toggleable, default is off.
Definition Shape.hpp:292
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
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 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
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
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::vector< ShapeRef > ShapeList
Definition Shape.hpp:81
std::shared_ptr< Shape > ShapeRef
Definition Shape.hpp:80
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
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
Author: Sven Gothel sgothel@jausoft.com Copyright Gothel Software e.K.
Definition enum_util.hpp:65
int printf(const char *format,...)
Operating Systems predefined macros.