Click or drag to resize
SoLightModel Class

Node that defines the lighting model to use when rendering.

Inheritance Hierarchy

Namespace: OIV.Inventor.Nodes
Assembly: OIV.Inventor (in OIV.Inventor.dll) Version: 2024.1.0.0 (2024.1.0)
Syntax
public class SoLightModel : SoNode

The SoLightModel type exposes the following members.

Constructors
  NameDescription
Public methodSoLightModel

Creates a light model node with default settings.

Top
Methods
  NameDescription
Public methodAffectsState

Returns true if a node has an effect on the state during traversal.

(Inherited from SoNode.)
Public methodCallback
Public methodCopy
Calls Copy(false).
(Inherited from SoNode.)
Public methodCopy(Boolean)

Creates and returns an exact copy of the node.

(Inherited from SoNode.)
Public methodCopyFieldValues(SoFieldContainer)
Calls CopyFieldValues(fc, false).
(Inherited from SoFieldContainer.)
Public methodCopyFieldValues(SoFieldContainer, Boolean)

Copies the contents of fc's fields into this object's fields.

(Inherited from SoFieldContainer.)
Public methodDispose
Releases all resources used by SoDisposable.
(Inherited from SoDisposable.)
Public methodDistribute
(Inherited from SoNode.)
Public methodDoAction
Public methodEnableNotify

Notification at this Field Container is enabled (if flag == true) or disabled (if flag == false).

(Inherited from SoFieldContainer.)
Public methodEquals
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Public methodFieldsAreEqual

Returns true if this object's fields are exactly equal to fc's fields.

(Inherited from SoFieldContainer.)
Public methodGet

Returns the values of the fields of this object in the Open Inventor ASCII file format in the given string.

(Inherited from SoFieldContainer.)
Public methodGetAllFields

Returns a list of fields, including the eventIn's and eventOut's.

(Inherited from SoFieldContainer.)
Public methodGetAlternateRep

This method is called by actions to allow the node to provide an "alternate representation" when appropriate (typically depending on the action type).

(Inherited from SoNode.)
Public methodGetBoundingBox
(Inherited from SoNode.)
Public methodGetEventIn

Returns a the eventIn with the given name.

(Inherited from SoFieldContainer.)
Public methodGetEventOut

Returns the eventOut with the given name.

(Inherited from SoFieldContainer.)
Public methodGetField

Returns a the field of this object whose name is fieldName.

(Inherited from SoFieldContainer.)
Public methodGetFieldName

Returns the name of the given field in the fieldName argument.

(Inherited from SoFieldContainer.)
Public methodGetFields

Appends references to all of this object's fields to resultList, and returns the number of fields appended.

(Inherited from SoFieldContainer.)
Public methodGetHashCode
Overrides GetHashCode().
(Inherited from SoNetBase.)
Public methodGetMatrix
(Inherited from SoNode.)
Public methodGetName

Returns the name of an instance.

(Inherited from SoBase.)
Public methodGetPrimitiveCount
(Inherited from SoNode.)
Public methodGetRenderEngineMode

Returns the supported Render engine mode.

(Inherited from SoNode.)
Public methodGetRenderUnitID
(Inherited from SoNode.)
Public methodGetStringName (Inherited from SoBase.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodGLRender
Public methodGLRenderBelowPath
(Inherited from SoNode.)
Public methodGLRenderInPath
(Inherited from SoNode.)
Public methodGLRenderOffPath
(Inherited from SoNode.)
Public methodGrabEventsCleanup
(Inherited from SoNode.)
Public methodGrabEventsSetup
(Inherited from SoNode.)
Public methodHandleEvent
(Inherited from SoNode.)
Public methodHasDefaultValues

Returns true if all of the object's fields have their default values.

(Inherited from SoFieldContainer.)
Public methodIsBoundingBoxIgnoring

This method is used by getBoundingBox action traversal to know if the current node must be traversed or not, ie the bounding should be ignored.

(Inherited from SoNode.)
Public methodIsNotifyEnabled

Notification is the process of telling interested objects that this object has changed.

(Inherited from SoFieldContainer.)
Public methodIsOverride

Returns the state of the override field.

(Overrides SoNodeIsOverride.)
Public methodIsSynchronizable

Gets the ScaleViz synchronizable state of this object.

(Inherited from SoBase.)
Public methodPick
(Inherited from SoNode.)
Public methodRayPick
(Inherited from SoNode.)
Public methodSearch
(Inherited from SoNode.)
Public methodSet

Sets one or more fields in this object to the values specified in the given string, which should be a string in the Open Inventor file format.

(Inherited from SoFieldContainer.)
Public methodSetName (Inherited from SoBase.)
Public methodSetOverride

Set the state of the override field.

(Overrides SoNodeSetOverride(Boolean).)
Public methodSetSynchronizable

Sets this to be a ScaleViz synchronizable object.

(Inherited from SoBase.)
Public methodSetToDefaults

Sets all fields in this object to their default values.

(Inherited from SoFieldContainer.)
Public methodToString
Converts this SoBase structure to a human readable string.
(Inherited from SoBase.)
Public methodTouch

Marks an instance as modified, simulating a change to it.

(Inherited from SoNode.)
Public methodWrite
(Inherited from SoNode.)
Top
Properties
  NameDescription
Public propertyIsDisposable
ISafeDisposable interface implementation.
(Inherited from SoDisposable.)
Public propertymodel

Lighting model to use .

Public propertyUserData
Gets or sets the user data to be contained by the field container.
(Inherited from SoFieldContainer.)
Top
Remarks

This node defines the lighting model to be used when rendering subsequent shapes. The lighting model is specified in the OIV.Inventor.Nodes.SoLightModel.model field which is PER_VERTEX_PHONG by default.

Several types of light model are supported and the following images are examples of rendering of the same scene using a different light model.

OIV.Inventor.Nodes.SoLightModel.Models.BASE_COLOROIV.Inventor.Nodes.SoLightModel.Models.PER_PIXEL_PHONGOIV.Inventor.Nodes.SoLightModel.Models.PHYSICALLY_BASED

When the light model is not OIV.Inventor.Nodes.SoLightModel.Models.BASE_COLOR, there must be light nodes (e.g. OIV.Inventor.Nodes.SoDirectionalLight) in the scene graph for objects to be easily visible. When using the Open Inventor viewer classes (e.g. OIV.Inventor.Win.Viewers.SoWinExaminerViewer), the viewer will create a "headlight" (directional light attached to the camera) if no other light nodes exist when setSceneGraph() is called. When using the Open Inventor viewer components (e.g. SceneExaminer), a "headlight" is automatically added to the scene graph.

An OIV.Inventor.Nodes.SoEnvironment node can be used to specify additional options related to lighting:

# Definition of base color

All the light models supported by Open Inventor use the concept of base color composed by 3 channels red green blue (rgb). It corresponds to the color of an object before being altered by light effects. Unfortunatly the term of *base color* is not always used in the API and documentation, sometimes it can be a mentionned as *diffuse color*, sometimes it can be a *rgb color*, a *rgb* or just a *color*.

The following fields define the same concept of *base color* of an object:

Thus, the following code C++ samples are equivalent and define a single red opaque base color:

mySoMaterial->diffuseColor = SbColor(1,0,0);
mySoMaterial->transparency = 0 ;

mySoPhysicalMaterial->baseColor = SbColorRGBA(1,0,0,1);

mySoBaseColor->rgb = SbColor(1,0,0);

mySoPackedColor->orderedRGBA = SbColorRGBA(1,0,0,1).getPackedValue();

mySoColorMap->colorMap.setValues(0, 4, new float[4]{ 1, 0, 0, 1 });

mySoBufferedShape->colorBuffer = new SoCpuBufferObject(new float[4]{ 1, 0, 0, 1 }, 4 * sizeof(float));

mySoVertexProperty->orderedRGBA = SbColorRGBA(1,0,0,1).getPackedValue();

Moreover, changing the value of any of those fields override the *base color* of an object. It means that if 2 different fields are set to specify a color, the current definition of a color during the scene graph traversal overrides the previous one. For instance, the following code sample specifies an opaque red color that overrides the semi opaque green

mySoPhysicalMaterial.baseColor.SetValue(new SbColorRGBA(0,1,0,0.5f)); // semi opaque green color
mySoMaterial.diffuseColor.SetValue(new SbColor(1,0,0)); // red color
mySoMaterial.transparency.SetValue(0);
myRoot.addChild(mySoPhysicalMaterial);
myRoot.addChild(mySoMaterial); // this red material overrides the green color

# Light model and property nodes

According to the light model selected, the following notes explain what is taken into account in the scene graph, and what is ignored:

Using model OIV.Inventor.Nodes.SoLightModel.Models.BASE_COLOR

Using OIV.Inventor.Nodes.SoLightModel.Models.PER_VERTEX_PHONG or OIV.Inventor.Nodes.SoLightModel.Models.PER_PIXEL_PHONG

Using OIV.Inventor.Nodes.SoLightModel.Models.PHYSICALLY_BASED

# Two side lighting

By default, lighting is only computed for the "front" faces of geometry, so the back face of the geometry will be dark. The front face is determined by the normal vector, if specified, or by the vertex ordering (see OIV.Inventor.Nodes.SoShapeHints) if normals are computed by Open Inventor. To enable "two sided" lighting (lighting both front and back faces) see OIV.Inventor.Nodes.SoShapeHints.

# Light model and VolumeViz

The OIV.Inventor.Nodes.SoLightModel node controls lighting for most VolumeViz shapes, but *not* for OIV.VolumeViz.Nodes.SoVolumeRender. The lighting for volume rendering is controlled by the OIV.VolumeViz.Nodes.SoVolumeRenderingQuality node.

Two sided lighting is automatically enabled for "slice" shapes, such as OIV.VolumeViz.Nodes.SoOrthoSlice.

FILE FORMAT/DEFAULT

LightModel {
model PER_PIXEL_PHONG
}

ACTION BEHAVIOR

OIV.Inventor.Actions.SoGLRenderAction, OIV.Inventor.Actions.SoCallbackAction Sets the current lighting model in the state.

See Also