Skip to content

niSpotLight⚓︎

Represents a spotlight in a scene. The street lights, emmithing the illumination in the cone shape can be represented by this class. Spotlights have a specific location and direction, as well as a distance attenuation and angle attenuation functions. The light direction is handled in the same way as in niDirectionalLight - it shines down the model-space positive X axis of the light.

This type inherits the following: niPointLight, niLight, niDynamicEffect, niAVObject, niObjectNET, niObject

Properties⚓︎

affectedNodes⚓︎

The list of nodes that a given dynamic effect will affect.

Returns:


alphaProperty⚓︎

Convenient access to this object's alpha property. Setting this value to be nil will erase the property, while setting it to a valid alpha property will set (or replace) it.

Returns:


ambient⚓︎

The ambient light color.

Returns:


appCulled⚓︎

A flag indicating if this object is culled. When culled, it will not render, and raycasts ignore it.

Returns:

  • result (boolean)

constantAttenuation⚓︎

The constant attenuation factor.

Returns:

  • result (number)

controller⚓︎

Read-only. The first controller available on the object.

Returns:


diffuse⚓︎

The diffuse light color.

Returns:


dimmer⚓︎

This flag scales the overall brightness of all light components. This value must be nonnegative. It is usually less than or equal to 1.0 (although advanced lighting effects may use larger values).

Returns:

  • result (number)

direction⚓︎

The direction of the axis of the spotlight cone from the light location in world space.

Returns:


enabled⚓︎

The enabled state of a given dynamic effect.

Returns:

  • result (boolean)

extraData⚓︎

Read-only. The first extra data available on the object.

Returns:


flags⚓︎

Flags, dependent on the specific object type.

Returns:

  • result (number)

fogProperty⚓︎

Convenient access to this object's fog property. Setting this value to be nil will erase the property, while setting it to a valid fog property will set (or replace) it.

Returns:


linearAttenuation⚓︎

The linear attenuation factor.

Returns:

  • result (number)

materialProperty⚓︎

Convenient access to this object's material property. Setting this value to be nil will erase the property, while setting it to a valid material property will set (or replace) it.

Returns:


name⚓︎

The human-facing name of the given object.

Returns:

  • result (string)

parent⚓︎

Read-only. The object's parent. It may not have one if it is not attached to the scene.

Returns:


properties⚓︎

Read-only. The list of properties attached to this niAVObject.

Returns:


quadraticAttenuation⚓︎

The quadratic attenuation factor.

Returns:

  • result (number)

refCount⚓︎

Read-only. The number of references that exist for this object. When this value reaches zero, the object will be deleted.

Returns:

  • result (number)

rotation⚓︎

The object's local rotation matrix.

Returns:


RTTI⚓︎

Read-only. The runtime type information for this object. This is an alias for the .runTimeTypeInformation property.

Returns:


runTimeTypeInformation⚓︎

Read-only. The runtime type information for this object.

Returns:


scale⚓︎

The object's local uniform scaling factor.

Returns:

  • result (number)

specular⚓︎

This property was inteded to be specular light color in NetImmerse, but in Morrowind it represents the dynamic culling radius. All the color channels are equal to the radius.

In practice, this radius represents the light's influence radius.

Returns:


spotAngle⚓︎

The spotlight angle, in degrees. Controls the size of the light's cone.

Returns:

  • result (number)

spotExponent⚓︎

The spotlight angular attenuation exponent. This value may be ignored.

Returns:

  • result (number)

stencilProperty⚓︎

Convenient access to this object's stencil property. Setting this value to be nil will erase the property, while setting it to a valid stencil property will set (or replace) it.

Returns:


texturingProperty⚓︎

Convenient access to this object's texturing property. Setting this value to be nil will erase the property, while setting it to a valid texturing property will set (or replace) it.

Returns:


translation⚓︎

The object's local translation vector.

Returns:


type⚓︎

Read-only. The enumerated type of a given dynamic effect. Maps to values in ni.dynamicEffectType table.

Returns:


velocity⚓︎

The object's local velocity.

Returns:


vertexColorProperty⚓︎

Convenient access to this object's vertex coloring property. Setting this value to be nil will erase the property, while setting it to a valid vertex coloring property will set (or replace) it.

Returns:


worldBoundOrigin⚓︎

The world coordinates of the object's bounds origin.

Returns:


worldBoundRadius⚓︎

The radius of the object's bounds.

Returns:

  • result (number)

worldTransform⚓︎

The object's transformations in the world space.

Returns:


zBufferProperty⚓︎

Convenient access to this object's z-buffer property. Setting this value to be nil will erase the property, while setting it to a valid z-buffer property will set (or replace) it.

Returns:


Methods⚓︎

addExtraData⚓︎

Appends an extra data to the object.

myObject:addExtraData(extraData)

Parameters:


attachAffectedNode⚓︎

Adds a node to the dynamic effect's affected nodes list. The node's :updateEffects() function should be called afterwards to recognize the change.

myObject:attachAffectedNode(node)

Parameters:

  • node (niNode): The node to add to the affected nodes list.

attachProperty⚓︎

Attaches a property to this object, without checking to see if the property or another of its type is already on the list. Property lists must not have more than one property of a given class (i.e. no two niTexturingProperty objects) attached at once, or else undefined behavior will result.

myObject:attachProperty(property)

Parameters:


clearTransforms⚓︎

Resets the object's local transform.

myObject:clearTransforms()

clone⚓︎

Creates a copy of this object.

local result = myObject:clone()

Returns:


copyTransforms⚓︎

Update object's local transform by copying from another source.

myObject:copyTransforms(source)

Parameters:


detachAffectedNode⚓︎

Removes a node from the dynamic effect's affected nodes list. The node's :updateEffects() function should be called afterwards to recognize the change.

myObject:detachAffectedNode(node)

Parameters:

  • node (niNode): The node to remove from the affected nodes list.

detachAllProperties⚓︎

Detaches all the properties on the object and returns them in the table.

local result = myObject:detachAllProperties()

Returns:


detachProperty⚓︎

Detaches and returns a property from the object which matches the given property type.

local result = myObject:detachProperty(type)

Parameters:

Returns:


getGameReference⚓︎

Searches for an niExtraData on this object to see if it has one that holds a related reference.

local reference = myObject:getGameReference(searchParents)

Parameters:

  • searchParents (boolean): Default: false. If true, all parent objects (if applicable) are also searched.

Returns:


getObjectByName⚓︎

Searches this node and all child nodes recursively for a node with a name that matches the argument.

local result = myObject:getObjectByName(name)

Parameters:

  • name (string)

Returns:


getProperty⚓︎

Gets an attached property by property type.

local result = myObject:getProperty(type)

Parameters:

Returns:


getStringDataStartingWith⚓︎

Searches for an niExtraData on this object to see if it has niStringExtraData that has its string start with the provided value argument.

local extra = myObject:getStringDataStartingWith(value)

Parameters:

  • value (string): The first niStringExtraData starting with this value will be returned.

Returns:


getStringDataWith⚓︎

Searches for an niExtraData on this object to see if it has niStringExtraData that has the provided value argument in its string field.

local extra = myObject:getStringDataWith(value)

Parameters:

  • value (string): The first niStringExtraData with this word will be returned.

Returns:


hasStringDataStartingWith⚓︎

Searches for an niExtraData on this object to see if it has niStringExtraData that has its string start with the provided value argument. Returns true if the value was found.

local result = myObject:hasStringDataStartingWith(value)

Parameters:

  • value (string): The value to search for.

Returns:

  • result (boolean)

hasStringDataWith⚓︎

Searches for an niExtraData on this object to see if it has niStringExtraData that contains the provided value argument in its string field. Returns true if the value was found.

local result = myObject:hasStringDataWith(value)

Parameters:

  • value (string): The value to search for.

Returns:

  • result (boolean)

isAppCulled⚓︎

Recursively checks if either the object or any of its parents are appCulled.

local result = myObject:isAppCulled()

Returns:

  • result (boolean)

isFrustumCulled⚓︎

Checks if the object is frustum culled for the given camera.

local result = myObject:isFrustumCulled(camera)

Parameters:

Returns:

  • result (boolean)

isInstanceOfType⚓︎

Determines if the object is of a given type, or of a type derived from the given type.

local result = myObject:isInstanceOfType(type)

Parameters:

Returns:

  • result (boolean)

isOfType⚓︎

Determines if the object is of a given type.

local result = myObject:isOfType(type)

Parameters:

Returns:

  • result (boolean)

prependController⚓︎

Add a controller to the object as the first controller.

myObject:prependController(controller)

Parameters:


propagatePositionChange⚓︎

Alias for update() method. Updates the world transforms of this node and its children, which makes changes visible for rendering. Use after changing any local rotation, translation, scale, bounds or after attaching and detaching nodes.

Tip

It's best to "batch up" calls to this method. For example, when transform of an object its parent and grandparent are all changed during the same frame, it is much more efficient to call this method only on the grandparent object after all transforms have been changed. Also, consider calling this function as low as possible on a scene graph.

myObject:propagatePositionChange({ time = ..., controllers = ..., bounds = ... })

Parameters:

  • args (table): Optional.
    • time (number): Default: 0. This parameter is the time-slice for transformation and bounds updates
    • controllers (boolean): Default: false. Update object's controllers?
    • bounds (boolean): Default: true. Update object's bounds?

removeAllControllers⚓︎

Removes all controllers.

myObject:removeAllControllers()

removeAllExtraData⚓︎

Removes all extra data.

myObject:removeAllExtraData()

removeController⚓︎

Removes a controller from the object.

myObject:removeController(controller)

Parameters:


removeExtraData⚓︎

Removes a specific extra data from the object.

myObject:removeExtraData(extraData)

Parameters:


saveBinary⚓︎

Serializes the object, and writes it to the given file.

local success = myObject:saveBinary(path)

Parameters:

  • path (string): The path to write the file at, relative to the Morrowind installation folder.

Returns:

  • success (boolean): If true the object was successfully serialized.

setAttenuationForRadius⚓︎

Sets the light attenuation values for the given radius. Respects the values in the Morrowind.ini file.

myObject:setAttenuationForRadius(radius)

Parameters:

  • radius (integer)

setFlag⚓︎

Sets a given flag in the niObjectNET flag data. The specifics use of the flag is dependent on the real underlying type.

myObject:setFlag(state, index)

Parameters:

  • state (boolean)
  • index (number)

setRadius⚓︎

Sets both the light's influence radius, and its lighting attenuation to match the radius.

myObject:setRadius(radius)

Parameters:

  • radius (integer)

update⚓︎

Updates the world transforms of this node and its children, which makes changes visible for rendering. Use after changing any local rotation, translation, scale, bounds or after attaching and detaching nodes.

Update Efficiency

It's best to "batch up" calls to this method. For example, when transform of an object its parent and grandparent are all changed during the same frame, it is much more efficient to call this method only on the grandparent object after all transforms have been changed. Also, consider calling this function as low as possible on a scene graph.

myObject:update({ time = ..., controllers = ..., children = ... })

Parameters:

  • args (table): Optional.
    • time (number): Default: 0. This parameter is passed to controllers. Only needed if controllers are being updated.
    • controllers (boolean): Default: false. Update controllers before updating transforms.
    • children (boolean): Default: true. Recursively updates the children of this node.

updateEffects⚓︎

Update all attached effects. This method must be called at or above any object when dynamic effects are attached or detached from it

myObject:updateEffects()

updateProperties⚓︎

Update all attached properties.

myObject:updateProperties()

Functions⚓︎

new⚓︎

Creates a new niPointLight. Sets the light's constant attenuation to 0, linear attenuation to 1 and quadratic attenuation to 0.

local light = niPointLight.new()

Returns: