Toggle navigation
ivorium
iv_components
Example project
GitHub
Main Page
Modules
Classes
Files
File List
File Members
ivorium_graphics
Elements
Elem.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include "
ElementRenderer.hpp
"
4
#include "../Rendering/CameraState.hpp"
5
#include "../Rendering/FlatShader.hpp"
6
7
#include <
ivorium_systems/ivorium_systems.hpp
>
8
9
namespace
iv
10
{
11
12
class
Camera;
13
16
class
Elem
:
public
InputNode
17
{
18
public
:
19
ClientMarker
cm
;
20
Elem
(
Instance
* inst );
21
~Elem
();
22
23
void
status
(
iv::TableDebugView
* view );
24
25
Instance
*
instance
()
const
;
26
27
28
//------------------------- element tree --------------------------------
31
void
elem_setParent
(
Elem
* );
32
35
Elem
*
elem_getParent
();
36
39
virtual
Camera
*
elem_getRoot
();
40
44
virtual
void
elem_eachChild
( std::function<
void
(
Elem
* ) >
const
& ){}
45
48
virtual
void
elem_childDisconnect
(
Elem
* ){}
49
50
//------------------------- scene update traversal --------------------------------
64
void
first_pass
(
ElementRenderer
* );
65
74
void
second_pass
(
ElementRenderer
* );
75
76
//
77
unsigned
first_pass_frame_id
();
78
unsigned
second_pass_frame_id
();
79
80
//------------------------- parameters --------------------------------
81
// initialization parameters
87
DirtyAttr< bool >
attr_enabled
;
88
89
// inherited parameter
90
DirtyAttr< float4x4 >
modelTransform
;
91
DirtyAttr< ShaderScissor >
scissor
;
92
93
// utility methods
94
Elem
*
enabled
(
bool
val );
95
99
void
quiet
(
bool
);
100
bool
quiet
()
const
;
101
102
//------------------------- utilities --------------------------------
103
// math over modelTransform
104
float3
FromLocalSpaceToScreenSpace
(
float3
local_space );
105
float3
FromScreenSpaceToLocalSpace
(
float3
screen_space );
106
float2
FromScreenPlaneToLocalPlane
(
float2
screen_space );
107
108
// input tree utilities
109
void
Add_InputNode
(
InputNode
* node );
110
void
Remove_InputNode
(
InputNode
* node );
111
112
protected
:
113
// InputNode
114
virtual
void
input_childDisconnect
(
InputNode
* )
override
;
115
virtual
void
input_eachChild
( std::function<
void
(
InputNode
* ) >
const
& )
override
;
116
117
// Elem
118
virtual
void
first_pass_impl
(
ElementRenderer
* ) = 0;
119
virtual
void
second_pass_impl
(
ElementRenderer
* ){}
120
121
private
:
122
Instance
* inst;
123
unsigned
_first_pass_frame_id;
124
unsigned
_second_pass_frame_id;
125
bool
_quiet;
126
std::vector< InputNode * > _input_children;
127
Elem
* _elem_parent;
128
};
129
130
class
Pickable
131
{
132
public
:
133
ClientMarker
cm
;
134
135
Pickable
(
Elem
*
elem
);
136
virtual
bool
picking_test
(
int2
input_pos ) = 0;
137
138
Elem
*
elem
();
139
Elem
const
*
elem
()
const
;
140
141
private
:
142
Elem
* _elem;
143
};
144
145
}