Object

Object are basics entities in NRG and can represent anything from a camera, static geometry, dynamic geometry, skeletal mesh, sounds, lights, occluders, 3d texts, particle system etc...

By default an object always starts as an empty; simply a transformation data (which represent its location, rotation, and scale in space) and possibly some physics data. When an object is first initialized a base data type can be passed and as a result which will change its form and behaviors.

The root of an object is always the current Scene it resides in. Objects can also have attachments; these attachments are other objects that may or may not contain base data type. Once linked they will form a chain similar as a typical parent/child relationship; where the root transformation is passed down the entire upper hierarchy.

As an example you can have your player represented as a SkeletalMesh that holds a flashlight (a StaticMesh object) and the light itself (a LightSource object); you can then attach the light source to the flashlight and the flashlight to the Bone of the skeleton hand. Regardless of the movement of the player the flashlight and the light source will always follow the player's hand.

This is a simple example but this concept can be used to create much more complicated object structures that can manipulate in code (or using Nodes) dynamically at runtime.

On a side note, an empty might not look like much at first but they can be extremely useful. They can be used to handle internal location such as a respawn point, a checkpoint or in conjunction with physics data they can be used as triggers; such as a door opening, an elevator switch, a radar, an enemy sight and everything else you can possibly think off that "activate" something at any point in time.

See Also

Static Variables


Name Description
scene The Scene the object belongs to.
group The ObjectGroup the object is associated to, nil if none.
root Root of the object (if any) instead nil.
root_bone In the case the root is a SkeletalMesh a Bone can be specified to be the actual root.
physicobject The PhysicObject associated to the object; nil instead.
data Access the ObjectData associated to the object.
handler The Handler that manages the scripting functionalities for the current Object.
animation Animation structure that manage the actions associated to the active Object.
bounds The Bounds manage the bounding shapes of the object that will be used for clipping.
attachment_count Total amount of object(s) currently attached to the active Object.
variable_count Number of member Variable attached to the active Object.
constraint_count Total of transformation Constraint attached to the current Object.
sensor_count Amount of Sensor attached to the current Object.
uid Internal unique id to identify the Object globally.

Variables


Name Description
priority Custom priority assigned to the current Object.
model_matrix World space transformation of the Object.
acceleration Acceleration vector calculated from the transformation motion from one frame to another.
name A unique name assigned to the Object to identify it within the Scene is associated to.
flags Bit mask of options and tags assigned to the current Object.
renderlayer_mask Bit mask controlling on which RenderLayer the current Object will be displayed.
sticky Freezes the transformation of the Object by preventing it to be updated.
visible Toggle the visibility of the active Object On/Off.
selected Mark the Object as selected.
mirror Tag the Object to be mirrored.
location Directly access the Object basis_matrix location.
rotation Directly access the basis_matrix rotation of the current Object.
scale Directly access the scale of the Object basis_matrix.
basis_matrix 4x4 matrix representing the local transformation of the Object.

Functions


Name Description
AddPhysics Add physics to the current Object.
RemovePhysics Completely remove all physics behaviors from the object (if any).
AddAttachment Create a new attachment Object of a specific ObjectType.
AddEmpty Helper function that creates a empty Object attachment.
AddCamera Helper that creates a new Camera and attach it to the active Object.
AddStaticMesh Creates a new StaticMesh Object and it to the active Object.
AddDynamicMesh Helper that creates a DynamicMesh attachment.
AddAdaptiveMesh Function that creates an AdaptiveMesh and attach it to the current Object.
AddSkeletalMesh Creates a new SkeletalMesh Object and attach it to the active Object.
AddSoundSource Create a new SoundSource and parent it to the active Object.
AddLightSource Create a new LightSource and attach it to the active Object.
AddOccluder Helper function that creates and attach a new Occluder to the active Object.
AddText Function that help you create a new Text Object and parent it to the active Object.
AddParticleSystem Create a new ParticleSystem and attach it to the current Object.
AddEnergyField Creates a new EnergyField Object and attach it to the active Object.
AddRoute Append a new Route Object to the current Object calling this function.
AddRay Function to create and attach a new Ray Object to the active Object.
AddProbe Helper that creates and attach a new Probe to the active Object.
AddRegion Creates and attach a new Region to the active Object calling this helper.
GetAttachment Get a specific Object attachment using its name as key.
GetAttachmentAt Retrieve an attachment using its internal index as key.
GetAttachmentIndex Get the index of a specific attachment.
RemoveAttachment Remove a specific attachment from the active base Object.
RemoveAttachmentAt Remove a specific attachment Object using its index as key.
SwapAttachments Swap an existing attachment Object to a new index.
AddVariable Add a new member Variable to the current Object.
GetVariable Retrieve an existing Variable by name.
GetVariableIndex Retrieve the internal index of a specific Variable reference.
GetVariableAt Retrieve an existing Variable reference using its index.
RemoveVariable Remove a specific variable from the object.
RemoveVariableAt Remove a specific Variable located at the index passed to this function.
AddConstraint Add a new transformation Constraint to the active Object.
GetConstraint Helper to retrieve an existing Constraint using its name as key.
GetConstraintAt Retrieve a Constraint by index.
GetConstraintIndex Get the index of an exsiting Constraint maintained by the active Object.
SetConstraintIndex Change the priority of an exsiting Constraint.
RemoveConstraint Remove a specific Constraint.
RemoveConstraintAt Remove a specific Constraint using its internal index as key.
SwapConstraints Exchange the location of two Constraint.
AddSensor Create and attach a new Sensor to the active Object.
GetSensor Retrieve the reference of an existing Sensor by name.
GetSensorAt Retrieve an existing Sensor reference by index.
GetSensorIndex Get the index of a specific Sensor.
SetSensorIndex Move an existing Sensor to a specific index.
RemoveSensor Remove a specific Sensor.
RemoveSensorAt Remove a Sensor located at a specific index.
SwapSensors Exchange the location index of two existing Sensor.
DetectRootLoop Helper function that detect cyclic redundency in parent/child (root/attachment) relation of the active Object.
Attach Attach the active Object to another existing Object to create a parent child relationship.
Detach Detach the active Object from its root (if any).
Duplicate Clone the active Object.
Update Force the current Object to be updated.
UpdateBounds Manually force the Object Bounds to be updated.
Convert Convert the current Object to another ObjectType.
GetVariable Retrieve an existing member Variable using its name as key.
GetVariableAt Retrieve an Object member Variable using its index as key.
GetVariableIndex Get the internal index of an existing member Variable maintained by the active Object.
GetVariableBool Retrieve the value of an existing boolean member Variable.
SetVariableBool Set the value of an existing boolean member Variable.
GetVariableInt Retrieve the value of an existing integer member Variable associated to the current Object.
SetVariableInt Set the value of an existing integer Variable.
GetVariableFloat Retrieve the value of an existing float member Variable.
SetVariableFloat Set the value of an existing float member Variable.
GetVariableVec2 Retrieve the value of an existing 2d vector member Variable.
SetVariableVec2 Set the value of an existing vec2 member Variable.
GetVariableVec3 Retrieve the value of an existing tri-dimensional vector Variable.
SetVariableVec3 Set the value of an existing 3d vector member Variable.
GetVariableVec4 Retrieve the value of an existing vec4 member Variable.
SetVariableVec4 Set the value of an existing vec4 Variable.
GetVariableString Retrieve the character set of an existing string member Variable.
SetVariableString Set the value of an existing string member Variable.
MoveToScene Transfer the active Object to another Scene currently loaded.

ObjectSaveFlags


Flags that determine the type of data that should be cloned when duplicating or when an Object is manually saved.

  • fRename: Automatically rename the Object.
  • fData: Duplicate/save the ObjectData.
  • fRoot: Copy/save the root of the Object.
  • fHandler: Create a copy of the Handler maintained by the Object.
  • fAttachments: Duplicate/save the Object attachments.
  • fAnimations: Duplicate/save the Animation attached to the Object.
  • fVariables: Duplicate/save all member Variable associated with to the Object.
  • fObjectGroup: Keep the current ObjectGroup.
  • fSoundGroup: Keep the current SoundGroup (in the case the ObjectType is set to kSoundSource and the SoundSource is actually connected to an existing sound group).
  • fConstraints: Copy/save all transformation Constraint.
  • fSensors: Duplicate/save all existing Sensor attached to the Object.
  • fBoneConstraints: Duplicate/save all Bone constraints in the event the ObjectType is a kSkeletalMesh.
  • fPhysicsData: Duplicate/save all physics data.
  • fPhysicsConstraints: Copy/save all physic constraints (either all RigidConstraint or SoftConstraint depending on the type of PhysicObject is used by the Object).

ObjectType


Constant values used to define an object data type.

ObjectData


A structure that allows you to manipulate the active object data. Using the associated data type that is represented by the ObjectType of your object you will gain access to its variables, methods, and functions specific to that data class.

Static Variables


Name Description
type Return the object data ObjectType.
lens_type Sub data type used by Camera Object that determine the LensType to use.
speaker_type Sub data type used by SoundSource Object that determine the SpeakerType to use.
light_type Sub data type used by LightSource Object that determine the LightType to use.
system_type Sub data type used by ParticleSystem Object that determine the SystemType to use.
field_type Sub data type used by EnergyField Object that determine the FieldType to use.
route_type Sub data type used by Route Object that determine the RouteType to use.
ray_type Sub data type used by Ray Object that determine the RayType to use.
probe_type Sub data type used by Probe Object that determine the ProbeType to use.
camera Access the Camera data attached to the object; nil if the object data type is not kCamera.
staticmesh Access the StaticMesh data attached to the object; nil if the object data type is not kStaticMesh.
dynamicmesh Access the DynamicMesh data attached to the object; nil if the object data type is not kDynamicMesh.
adaptivemesh Access the AdaptiveMesh data attached to the object; nil if the object data type is not kAdaptiveMesh.
skeletalmesh Access the SkeletalMesh data attached to the object; nil if the object data type is not kSkeletalMesh.
fracturedmesh Access the FracturedMesh data attached to the object; nil if the object data type is not kFracturedMesh.
soundsource Access the SoundSource data attached to the object; nil if the object data type is not kSoundSource.
lightsource Access the LightSource data attached to the object; nil if the object data type is not kLightSource.
occluder Access the Occluder data attached to the object; nil if the object data type is not kOccluder.
text Access the Text data attached to the object; nil if the object data type is not kText.
particlesystem Access the ParticleSystem data attached to the object; nil if the object data type is not kParticleSystem.
energyfield Access the EnergyField data attached to the object; nil if the object data type is not kEnergyField.
route Access the Route data attached to the object; nil if the object data type is not kRoute.
ray Access the Ray data attached to the object; nil if the object data type is not kRay.
probe Access the Probe data attached to the object; nil if the object data type is not kProbe.
region Access the Region data attached to the object; nil if the object data type is not kRegion.

Base Events


Events that can be triggered by a base Object regardless of the ObjectType it is actually using.

Callbacks Description
OnUpdate This callback is triggered each time the Object gets updated.
OnCreate Occur once when the Object gets created.
OnDestroy Triggered once when the Object is about to be destroyed.
OnProximity Respond to the Sensor attached to the Object when detecting a changes in proximity data.
OnOverlap Triggered by PhysicObject when the AABB overlap with another physic object.
OnCollide Triggered when the PhysicObject associated with the current Object collide with another.
OnContact Triggered when two PhysicMaterial get in contact with each other (require collision callback to be enabled).




NRG - API 2022.2.380740 - Wed Jun 8 2022
Copyright © 2022 nrgcore.com. All Rights Reserved. Terms of Service - Privacy Policy - EULA