Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F123477
Node.h
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Size
4 KB
Referenced Files
None
Subscribers
None
Node.h
View Options
#ifndef _ECHONODE_H_
#define _ECHONODE_H_
#include
<echo/Types.h>
#include
<echo/Maths/Quaternion.h>
#include
<echo/Maths/Matrix4.h>
#include
<echo/Graphics/NodeInterface.h>
#include
<string>
#include
<set>
namespace
Echo
{
class
Node
:
public
NodeInterface
{
public
:
Node
(
const
Vector3
&
position
=
Vector3
::
ZERO
,
const
Quaternion
&
orientation
=
Quaternion
::
IDENTITY
,
const
Vector3
&
scale
=
Vector3
::
UNIT_SCALE
);
virtual
~
Node
();
const
std
::
string
&
GetName
()
const
;
void
SetName
(
const
std
::
string
&
val
);
virtual
const
Quaternion
&
GetOrientation
()
const
;
virtual
const
Quaternion
&
GetDerivedOrientation
()
const
;
virtual
const
Vector3
&
GetPosition
()
const
;
virtual
const
Vector3
&
GetDerivedPosition
()
const
;
virtual
const
Vector3
&
GetScale
()
const
;
virtual
const
Vector3
&
GetDerivedScale
()
const
;
virtual
void
SetDerivedPosition
(
const
Vector3
&
derivedPosition
);
virtual
void
SetDerivedScale
(
const
Vector3
&
derivedScale
);
virtual
void
SetDerivedOrientation
(
const
Quaternion
&
derivedOrientation
);
/**
* Get the transform of this node.
* The transform returned reflects the derived position, scale and orientation.
* @return transform matrix for the node.
*/
const
Matrix4
&
GetTransform
();
/**
* Get the local transform of this node.
* The transform returned reflects the local position, scale and orientation.
* @return
*/
const
Matrix4
&
GetLocalTransform
();
const
Quaternion
&
GetInitialOrientation
()
const
;
const
Vector3
&
GetInitialPosition
()
const
;
const
Vector3
&
GetInitialScale
()
const
;
const
bool
&
GetInheritOrientation
()
const
;
const
bool
&
GetInheritScale
()
const
;
virtual
void
SetOrientation
(
const
Quaternion
&
val
);
/**
* Set the position of the node.
*/
virtual
void
SetPosition
(
const
Vector3
&
val
);
/**
* Set the scale of the node.
* You can set a non-uniform scale.
*/
virtual
void
SetScale
(
const
Vector3
&
val
);
/**
* Set the position of the node.
*/
virtual
void
SetPosition
(
f32
x
,
f32
y
,
f32
z
);
/**
* Set a uniform scale.
* @param scale
*/
virtual
void
SetUniformScale
(
f32
scale
);
void
SetTransform
(
const
Matrix4
&
val
);
void
SetInitialOrientation
(
const
Quaternion
&
val
);
void
SetInitialPosition
(
const
Vector3
&
val
);
void
SetInitialScale
(
const
Vector3
&
val
);
void
SetInheritOrientation
(
const
bool
&
val
);
void
SetInheritScale
(
const
bool
&
val
);
virtual
void
Scale
(
const
Vector3
&
s
);
virtual
void
Translate
(
const
Vector3
&
t
);
virtual
void
TranslateRelative
(
const
Vector3
&
t
);
virtual
void
Rotate
(
const
Vector3
&
axis
,
const
Radian
&
angle
);
virtual
void
Rotate
(
const
Quaternion
&
rotation
);
virtual
void
Yaw
(
Radian
angle
);
virtual
void
Pitch
(
Radian
angle
);
virtual
void
Roll
(
Radian
angle
);
//SetParent() CHANGES the parent of the node.
void
SetParent
(
Node
*
node
);
Node
*
GetParent
()
const
;
void
AddChild
(
Node
*
node
,
bool
takeOwnerShip
=
false
);
void
AddChild
(
Node
&
node
);
Node
*
CreateChild
(
const
std
::
string
&
name
);
Node
*
CreateChild
(
const
std
::
string
&
name
,
const
Vector3
&
position
=
Vector3
::
ZERO
,
const
Quaternion
&
rotation
=
Quaternion
::
IDENTITY
);
bool
RemoveChild
(
const
std
::
string
&
name
);
bool
RemoveChild
(
Node
&
node
);
void
RemoveAllChildren
();
void
_Update
(
bool
updateChildren
,
bool
parentHasChanged
);
//This method is a slow lookup
Node
*
GetChild
(
const
std
::
string
&
name
)
const
;
//Reset the node to the initial position
void
Reset
();
protected
:
std
::
set
<
Node
*
>
mChildNodes
;
std
::
set
<
Node
*
>
mChildrenToUpdate
;
std
::
set
<
Node
*
>
mChildrenToDelete
;
Node
*
mParent
;
Quaternion
mOrientation
;
mutable
Quaternion
mDerivedOrientation
;
Vector3
mPosition
;
mutable
Vector3
mDerivedPosition
;
Vector3
mScale
;
mutable
Vector3
mDerivedScale
;
Matrix4
mTransform
;
Matrix4
mLocalTransform
;
Quaternion
mInitialOrientation
;
Vector3
mInitialPosition
;
Vector3
mInitialScale
;
bool
mInheritOrientation
;
bool
mInheritScale
;
mutable
bool
mNeedsParentUpdate
;
bool
mNotifiedParentOfUpdate
;
bool
mNeedChildUpdate
;
mutable
bool
mTransformOutOfDate
;
mutable
bool
mLocalTransformOutOfDate
;
bool
mDeleteChildNodesOnDelete
;
std
::
string
mName
;
void
ApplyDefaults
(
const
Vector3
&
position
,
const
Quaternion
&
orientation
,
const
Vector3
&
scale
);
void
_UpdateFromParent
()
const
;
virtual
void
OnParentSet
(
Node
*
node
);
virtual
void
NeedUpdate
(
bool
forceParent
=
false
);
virtual
void
ChildRequestUpdate
(
Node
&
node
,
bool
forceParentUpdate
);
virtual
void
CancelChildUpdate
(
Node
&
node
);
virtual
void
ChildAdded
(
Node
&
node
);
virtual
void
ChildRemoved
(
Node
&
node
);
};
}
#endif
File Metadata
Details
Attached
Mime Type
text/x-c++
Expires
Thu, Jan 16, 12:34 AM (13 h, 6 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
72104
Default Alt Text
Node.h (4 KB)
Attached To
Mode
rEE Echo 3
Attached
Detach File
Event Timeline
Log In to Comment