Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F123447
Cursor.cpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
Cursor.cpp
View Options
#include
<echo/GUI/Element.h>
#include
<echo/GUI/Cursor.h>
#include
<echo/Graphics/Renderer.h>
#include
<echo/Maths/Ray.h>
namespace
Echo
{
namespace
GUI
{
Cursor
::
Cursor
(
shared_ptr
<
Input
<
bool
>
>
button
,
shared_ptr
<
Input
<
f32
>
>
xInput
,
shared_ptr
<
Input
<
f32
>
>
yInput
,
shared_ptr
<
Element
>
rootElement
,
shared_ptr
<
Renderer
>
renderer
,
shared_ptr
<
Element
>
cursorElement
)
:
mButton
(
button
),
mX
(
xInput
),
mY
(
yInput
),
mRootElement
(
rootElement
),
mCursorElement
(
cursorElement
),
mRenderer
(
renderer
)
{
}
bool
Cursor
::
OnStart
()
{
//Prevent starting this task if we have any null required parameters.
return
(
mRenderer
&&
mRootElement
&&
mButton
&&
mX
&&
mY
);
}
void
Cursor
::
Update
(
Seconds
)
{
Ray
rayIntoScene
;
if
(
mRenderer
->
GetRayIntoScene
(
*
mX
,
*
mY
,
rayIntoScene
))
{
Plane
plane
(
Vector3
::
UNIT_Z
,
0.f
);
std
::
pair
<
bool
,
f32
>
intersectResult
=
rayIntoScene
.
Intersects
(
plane
);
if
(
intersectResult
.
first
)
{
Vector3
positionInSpace
=
rayIntoScene
.
GetPoint
(
intersectResult
.
second
);
if
(
mCursorElement
)
{
positionInSpace
.
z
=
mCursorElement
->
GetPosition
().
z
;
mCursorElement
->
SetPosition
(
positionInSpace
);
}
mRootElement
->
UpdateCursor
(
positionInSpace
.
x
,
positionInSpace
.
y
,
*
mButton
);
}
}
}
}
}
File Metadata
Details
Attached
Mime Type
text/x-c++
Expires
Wed, Jan 15, 11:33 PM (6 h, 1 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
72091
Default Alt Text
Cursor.cpp (1 KB)
Attached To
Mode
rEE Echo 3
Attached
Detach File
Event Timeline
Log In to Comment