Class SceneExtensions
Static extension methods on SceneNode and SceneComponent instances (or enumerations) for various purposes.
Inheritance
Inherited Members
Namespace: Fusee.Engine.Core.Scene
Assembly: Fusee.Engine.Core.dll
Syntax
public static class SceneExtensions
Methods
AddComponent(SceneNode, SceneComponent)
Adds the given component into this container's list of components.
Declaration
public static void AddComponent(this SceneNode snThisThis, SceneComponent scc)
Parameters
Type | Name | Description |
---|---|---|
SceneNode | snThisThis | This node. |
SceneComponent | scc | The component to add. |
FindComponents(SceneNode, Predicate<SceneComponent>)
Finds all components matching a given search predicate within the given node.
Declaration
public static IEnumerable<SceneComponent> FindComponents(this SceneNode root, Predicate<SceneComponent> match)
Parameters
Type | Name | Description |
---|---|---|
SceneNode | root | The root node where to start the traversal. |
System.Predicate<SceneComponent> | match | The matching predicate. Enumeration will yield on every matching node. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<SceneComponent> | An enumerable that can be used in foreach statements. |
Remarks
Narrows the generic parameters of FindComponents<TNode, TComponent>(TNode, Predicate<TComponent>) to the concrete Types SceneNode and SceneComponent.
FindComponents(IEnumerable<SceneNode>, Predicate<SceneComponent>)
Finds all components matching a given search predicate within the given list of nodes.
Declaration
public static IEnumerable<SceneComponent> FindComponents(this IEnumerable<SceneNode> roots, Predicate<SceneComponent> match)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<SceneNode> | roots | |
System.Predicate<SceneComponent> | match |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<SceneComponent> |
FindComponents<TComponentToFind>(SceneNode, Predicate<TComponentToFind>)
Finds all components of a certain type matching a given search predicate within the given node.
Declaration
public static IEnumerable<TComponentToFind> FindComponents<TComponentToFind>(this SceneNode root, Predicate<TComponentToFind> match)
where TComponentToFind : SceneComponent
Parameters
Type | Name | Description |
---|---|---|
SceneNode | root | The root node where to start the traversal. |
System.Predicate<TComponentToFind> | match | The matching predicate. Enumeration will yield on every matching node. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<TComponentToFind> | An enumerable that can be used in foreach statements. |
Type Parameters
Name | Description |
---|---|
TComponentToFind |
Remarks
Narrows the generic parameters of FindComponents<TNode, TComponent>(TNode, Predicate<TComponent>) to the concrete Types SceneNode and SceneComponent.
FindComponents<TComponentToFind>(IEnumerable<SceneNode>, Predicate<TComponentToFind>)
Finds all components of a certain type matching a given search predicate within the given list of nodes.
Declaration
public static IEnumerable<TComponentToFind> FindComponents<TComponentToFind>(this IEnumerable<SceneNode> roots, Predicate<TComponentToFind> match)
where TComponentToFind : SceneComponent
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<SceneNode> | roots | |
System.Predicate<TComponentToFind> | match |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<TComponentToFind> |
Type Parameters
Name | Description |
---|---|
TComponentToFind |
FindNodesWhereComponent(SceneNode, Predicate<SceneComponent>)
Finds all components matching a given search predicate within the given node.
Declaration
public static IEnumerable<SceneNode> FindNodesWhereComponent(this SceneNode root, Predicate<SceneComponent> match)
Parameters
Type | Name | Description |
---|---|---|
SceneNode | root | |
System.Predicate<SceneComponent> | match |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<SceneNode> |
FindNodesWhereComponent(IEnumerable<SceneNode>, Predicate<SceneComponent>)
Finds all components matching a given search predicate within the given node.
Declaration
public static IEnumerable<SceneNode> FindNodesWhereComponent(this IEnumerable<SceneNode> roots, Predicate<SceneComponent> match)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<SceneNode> | roots | |
System.Predicate<SceneComponent> | match |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<SceneNode> |
FpsView(Transform, Single, Single, Single, Single, Single)
Use this if the TransformComponent is part of a camera and you want to achieve a first person behavior.
Declaration
public static void FpsView(this Transform tc, float angleHorz, float angleVert, float inputWSAxis, float inputADAxis, float speed)
Parameters
Type | Name | Description |
---|---|---|
Transform | tc | This TransformComponent |
System.Single | angleHorz | The horizontal rotation angle in rad. Should probably come from Mouse input. |
System.Single | angleVert | The vertical rotation angle in rad. Should probably come from Mouse input. |
System.Single | inputWSAxis | The value we want to translate the camera when pressing the W or S key. |
System.Single | inputADAxis | The value we want to translate the camera when pressing the A or D key. |
System.Single | speed | Changes the speed of the camera movement. |
GetComponent(SceneNode, Type, Int32)
Finds the component with the specified type in this scene node container.
Declaration
public static SceneComponent GetComponent(this SceneNode snThisThis, Type type, int inx = 0)
Parameters
Type | Name | Description |
---|---|---|
SceneNode | snThisThis | This scene node container. |
System.Type | type | The type of the component to look for. |
System.Int32 | inx | specifies the n'th component if more than component of the given type exists. |
Returns
Type | Description |
---|---|
SceneComponent | A component of the specified type, if contained within the given container, null otherwise. |
GetComponent<TComp>(SceneNode, Int32)
Finds the component with the specified type in this scene node container.
Declaration
public static TComp GetComponent<TComp>(this SceneNode snThisThis, int inx = 0)
where TComp : SceneComponent
Parameters
Type | Name | Description |
---|---|---|
SceneNode | snThisThis | This scene node container. |
System.Int32 | inx | specifies the n'th component if more than component of the given type exists. |
Returns
Type | Description |
---|---|
TComp | A component of the specified type, if contained within this container, null otherwise. |
Type Parameters
Name | Description |
---|---|
TComp | The type of the component to look for. |
GetComponents(SceneNode, Type)
Finds the components with the specified type in this scene node container.
Declaration
public static IEnumerable<SceneComponent> GetComponents(this SceneNode snThisThis, Type type)
Parameters
Type | Name | Description |
---|---|---|
SceneNode | snThisThis | This scene node container. |
System.Type | type | The type of the component to look for. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<SceneComponent> |
GetComponents<TComp>(SceneNode)
Finds the components with the specified type in this scene node container.
Declaration
public static IEnumerable<TComp> GetComponents<TComp>(this SceneNode snThisThis)
where TComp : SceneComponent
Parameters
Type | Name | Description |
---|---|---|
SceneNode | snThisThis | This scene node container. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<TComp> | A component of the specified type, if contained within the given container, null otherwise. |
Type Parameters
Name | Description |
---|---|
TComp |
GetComponentsInChildren(SceneNode, Type)
Finds the components with the specified type and the sub-types in the children of this scene node container.
Declaration
public static IEnumerable<SceneComponent> GetComponentsInChildren(this SceneNode snThisThis, Type type)
Parameters
Type | Name | Description |
---|---|---|
SceneNode | snThisThis | This scene node container. |
System.Type | type | The type of the components to look for. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<SceneComponent> | A List of components of the specified type, if contained within the given container. |
GetComponentsInChildren<TComp>(SceneNode)
Finds the components with the specified type in the children of this scene node container.
Declaration
public static IEnumerable<TComp> GetComponentsInChildren<TComp>(this SceneNode snThisThis)
where TComp : SceneComponent
Parameters
Type | Name | Description |
---|---|---|
SceneNode | snThisThis | This scene node container. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<TComp> | A List of components of the specified type, if contained within the given container. |
Type Parameters
Name | Description |
---|---|
TComp | The type of the components to look for. |
GetGlobalRotation(SceneNode)
Returns the global rotation matrix as the product of all rotations along the scene graph branch this SceneNode is a part of.
Declaration
public static float4x4 GetGlobalRotation(this SceneNode snThis)
Parameters
Type | Name | Description |
---|---|---|
SceneNode | snThis |
Returns
Type | Description |
---|---|
float4x4 |
GetGlobalScale(SceneNode)
Returns the global scale as the product of all scaling along the scene graph branch this SceneNode is a part of.
Declaration
public static float3 GetGlobalScale(this SceneNode snThis)
Parameters
Type | Name | Description |
---|---|---|
SceneNode | snThis |
Returns
Type | Description |
---|---|
float3 |
GetGlobalTransformation(SceneNode)
Returns the global transformation matrix as the product of all transformations along the scene graph branch this SceneNode is a part of.
Declaration
public static float4x4 GetGlobalTransformation(this SceneNode snThis)
Parameters
Type | Name | Description |
---|---|---|
SceneNode | snThis |
Returns
Type | Description |
---|---|
float4x4 |
GetGlobalTranslation(SceneNode)
Returns the global translation as the product of all translations along the scene graph branch this SceneNode is a part of.
Declaration
public static float3 GetGlobalTranslation(this SceneNode snThis)
Parameters
Type | Name | Description |
---|---|---|
SceneNode | snThis |
Returns
Type | Description |
---|---|
float3 |
GetLight(SceneNode, Int32)
Declaration
public static Light GetLight(this SceneNode snThisThis, int inx = 0)
Parameters
Type | Name | Description |
---|---|---|
SceneNode | snThisThis | This scene node container. |
System.Int32 | inx | specifies the n'th component if more than component of the given type exists. |
Returns
Type | Description |
---|---|
Light | A light if contained within this container. |
GetLocalTransformation(Transform)
Get the local transformation matrix from this TransformationComponent.
Declaration
public static float4x4 GetLocalTransformation(this Transform tansThis)
Parameters
Type | Name | Description |
---|---|---|
Transform | tansThis |
Returns
Type | Description |
---|---|
float4x4 |
GetLocalTranslation(Transform)
Get the local transformation matrix from this TransformationComponent.
Declaration
public static float4x4 GetLocalTranslation(this Transform tansThis)
Parameters
Type | Name | Description |
---|---|---|
Transform | tansThis |
Returns
Type | Description |
---|---|
float4x4 |
GetMesh(SceneNode, Int32)
Declaration
public static Mesh GetMesh(this SceneNode snThisThis, int inx = 0)
Parameters
Type | Name | Description |
---|---|---|
SceneNode | snThisThis | This scene node container. |
System.Int32 | inx | specifies the n'th component if more than component of the given type exists. |
Returns
Type | Description |
---|---|
Mesh | A mesh if contained within this container. |
GetTransform(SceneNode, Int32)
Declaration
public static Transform GetTransform(this SceneNode snThisThis, int inx = 0)
Parameters
Type | Name | Description |
---|---|---|
SceneNode | snThisThis | This scene node container. |
System.Int32 | inx | specifies the n'th component if more than component of the given type exists. |
Returns
Type | Description |
---|---|
Transform | A transform if contained within this container. |
GetWeights(SceneNode, Int32)
Declaration
public static Weight GetWeights(this SceneNode snThisThis, int inx = 0)
Parameters
Type | Name | Description |
---|---|---|
SceneNode | snThisThis | This scene node container. |
System.Int32 | inx | specifies the n'th component if more than component of the given type exists. |
Returns
Type | Description |
---|---|
Weight | A weight component if contained within this container. |
RemoveComponent(SceneNode, Type, Int32)
Removes the component with the specified type in this scene node container.
Declaration
public static void RemoveComponent(this SceneNode snThisThis, Type type, int inx = 0)
Parameters
Type | Name | Description |
---|---|---|
SceneNode | snThisThis | This scene node container. |
System.Type | type | The type of the component to look for. |
System.Int32 | inx | specifies the n'th component if more than component of the given type exists. |
RemoveComponent<TComp>(SceneNode, Int32)
Removes the component with the specified type in this scene node container.
Declaration
public static void RemoveComponent<TComp>(this SceneNode snThisThis, int inx = 0)
where TComp : SceneComponent
Parameters
Type | Name | Description |
---|---|---|
SceneNode | snThisThis | This scene node container. |
System.Int32 | inx | specifies the n'th component if more than component of the given type exists. |
Type Parameters
Name | Description |
---|---|
TComp | The type of the component to look for. |
RemoveComponentsInChildren(SceneNode, Type)
Removes the components with the specified type and the sub-types in the children of this scene node container.
Declaration
public static void RemoveComponentsInChildren(this SceneNode snThisThis, Type type)
Parameters
Type | Name | Description |
---|---|---|
SceneNode | snThisThis | This scene node container. |
System.Type | type | The type of the components to look for. |
RemoveComponentsInChildren<TComp>(SceneNode)
Removes components with the specified type in the children of this scene node container.
Declaration
public static void RemoveComponentsInChildren<TComp>(this SceneNode snThisThis)
where TComp : SceneComponent
Parameters
Type | Name | Description |
---|---|---|
SceneNode | snThisThis | This scene node container. |
Type Parameters
Name | Description |
---|---|
TComp | The type of the components to look for. |
Rotate(Transform, float3)
Rotates this node.
Declaration
public static void Rotate(this Transform tc, float3 xyz)
Parameters
Type | Name | Description |
---|---|---|
Transform | tc | |
float3 | xyz | Rotation amount as float3. |
Rotate(Transform, float4x4)
Rotates this node.
Declaration
public static void Rotate(this Transform tc, float4x4 rotationMtx)
Parameters
Type | Name | Description |
---|---|---|
Transform | tc | |
float4x4 | rotationMtx | Rotation amount as represented in float4x4. |
Rotate(Transform, QuaternionF)
Rotates this node.
Declaration
public static void Rotate(this Transform tc, QuaternionF quaternion)
Parameters
Type | Name | Description |
---|---|---|
Transform | tc | |
QuaternionF | quaternion | Rotation amount in Quaternion. |
RotateAround(Transform, float3, float3)
Rotates around a center with the given angles. CAREFUL: this method will only produce correct results if a) the SceneNode of this transform is in the first level of the scene graph, directly beneath the SceneContainer b) this Transform's global rotation and translation equals its local ones (non of the SceneNodes that are in the levels above are translated or rotated).
Declaration
public static void RotateAround(this Transform tc, float3 center, float3 angles)
Parameters
Type | Name | Description |
---|---|---|
Transform | tc | |
float3 | center | |
float3 | angles |
RotateGlobal(Transform, QuaternionF, QuaternionF)
Rotates this node around the (static) global axis.
Declaration
public static void RotateGlobal(this Transform tc, QuaternionF rotation, QuaternionF parentGlobalRot)
Parameters
Type | Name | Description |
---|---|---|
Transform | tc | |
QuaternionF | rotation | Rotation amount as represented in Quaternion. |
QuaternionF | parentGlobalRot | Global (accumulated) rotation of the parent node. |
ToScene(SceneNode)
Converts the SceneNode to a Scene
Declaration
public static SceneContainer ToScene(this SceneNode snThis)
Parameters
Type | Name | Description |
---|---|---|
SceneNode | snThis | this node. |
Returns
Type | Description |
---|---|
SceneContainer |
ToSceneNode(SceneContainer)
Converts the Scene to a SceneNode with a separate Transform
Declaration
public static SceneNode ToSceneNode(this SceneContainer sc)
Parameters
Type | Name | Description |
---|---|---|
SceneContainer | sc | this node. |
Returns
Type | Description |
---|---|
SceneNode |
Translate(Transform, float3)
Translate this node.
Declaration
public static void Translate(this Transform tc, float3 xyz)
Parameters
Type | Name | Description |
---|---|---|
Transform | tc | |
float3 | xyz | Translation amount as float3. |
Translate(Transform, float4x4)
Translates a transform component with a specified float4x4 translation matrix
Declaration
public static void Translate(this Transform tc, float4x4 translationMtx)
Parameters
Type | Name | Description |
---|---|---|
Transform | tc | |
float4x4 | translationMtx | Translation amount as represented in float4x4. |