Work with Visual Nodes

Using Lua to intract with Visual nodes

This node describes visual attributes of an assembly such as its model and material.

Properties

Property

Type

Description

Enabled

boolean

Enabled or disabled. When disabled, any referenced model is not rendered.

Model

vrnode

Link to a model in the Libraries tree to render

Material

vrnode

Link to a material override to apply to all the GeoGroups in the Model, unless they are locked

CullFace

number

Cull face mode overriding the values in the GeoGroups. See the Cull Face mode table below.

DrawMode

number

Draw mode overriding the values in the GeoGroups. See the Draw Mode table below.

ShadowCaster

number

Shadow caster mode overriding the values in the GeoGroups. See the Shadow Caster table below.

Invert

boolean

Indicates whether the winding order of the model polygons is reversed (renders the model inside out)

Cull Face Modes

These modes control which faces of geometry in the model are rendered.

Mode

Description

__Visual_CullFaceNoOverride

Does not override the GeoGroup cull face mode

__Visual_CullFaceNone

Does not cull any faces (both back and front are drawn)

__Visual_CullFaceBack

Culls back faces

__Visual_CullFaceFront

Culls front faces

Draw Modes

These modes control how the model is rendered

Mode

Description

__Visual_DrawModeNoOverride

Does not override the GeoGroup draw mode

__Visual_DrawModeSolid

Forces solid rendering (model faces are filled)

__Visual_DrawModeLines

Forces line rendering (model is drawn as wireframe)

__Visual_DrawModePoints

Forces point rendering (only the vertices are drawn)

Shadow Caster Modes

Mode

Description

__Visual_ShadowCasterPerGeoGroup

Does not override the GeoGroup shadow casting mode

__Visual_ShadowCasterAll

Forces the whole model to cast shadows when lit by a shadow casting light

__Visual_ShadowCasterNone

Forces the whole model to not cast shadows when lit by a shadow casting light

Examples

Example 1

Example showing how to set and toggle the Enabled and Invert properties on a Visual, also how to set the Material override

-- Drag/Drop section BEGINS - Do not edit between BEGINS and ENDS.
local King_white = __Script.dragdrop.King_white
local Highlight = __Script.dragdrop.Highlight
-- Drag/Drop section ENDS

-- Sets Enabled to true
King_white.Visual.Enabled = true

-- Toggles the current Enabled setting
King_white.Visual.Enabled = not King_white.Visual.Enabled

-- Sets Invert to true
King_white.Visual.Invert = true

-- Toggles the current Invert setting
King_white.Visual.Invert = not King_white.Visual.Invert

-- Sets the override Material to Highlight
King_white.Visual.Material = Highlight

Example 2

Example showing how to check a Visual’s override material and change it depending on its current value, and also change its shadow caster mode

-- Drag/Drop section BEGINS - Do not edit between BEGINS and ENDS.
local King_white = __Script.dragdrop.King_white
local Highlight = __Script.dragdrop.Highlight
-- Drag/Drop section ENDS

if King_white.Visual.Material == Highlight then
  print("Set to no override and restore shadows")
  King_white.Visual.Material = nil
  King_white.Visual.ShadowCaster = __Visual_ShadowCasterPerGeoGroup
else
  print("Set to highlight material and disable shadows")
  King_white.Visual.Material = Highlight
  King_white.Visual.ShadowCaster = __Visual_ShadowCasterNone
end


No Results.

Getting StartedArchitectureBest PracticesHow ToAdvanced TopicsChangelogvrtreevrtree_cppvtCoreCoreForeign Function InterfaceMetanodesMigrationsObserversPropertiesSettingsTreeUtilitiesAPI DefinitionsVR ExchangePluginsLua API