CreateLightRigFromImage

詳細

指定のソース イメージから、専用のライト リグを作成します。このコマンドの機能は、[ライト]メニューから[イメージからライト リグ]を選択する操作に相当します。

ライト リグは、ソース イメージのライティングのカラー、方向、強度をシミュレートした一連の平行光です。 ライトは平行光ですので、シーン オブジェクトは場所とは無関係に同様に光ります。ライトの位置やリグのサイズについて注意する必要はありません。

注: このライト リグと LightRig プログラミング オブジェクトを混同しないでください。 シーン内のライト リグを検索すると、X3DObject.AddLightRig メソッドで作成されたオブジェクトは TypeName または「LightRig」という Application.ClassName 値を持ちます。一方、このコマンドで作成したライト リグは Null オブジェクトのままです。 詳細については、例を参照してください。

注: このコマンドは、出力引数を使用します。 一部のスクリプト言語(JScript や Python など)は、リファレンスによって渡される引数をサポートしません。 戻り値の配列を使って出力引数を取得する方法の詳細については、「出力引数、戻り値、および出力値の配列」を参照してください。

スクリプト構文

CreateLightRigFromImage( [Filename], [Number_Layers], [AreaHigh], [LightDistHigh] );

パラメータ

パラメータ タイプ 説明
Filename 文字列 対応しているイメージ フォーマットは、.pic および .hdr です。 イメージには必ず球体マップ(経度/緯度タイプのイメージ)を使用してください。 HDR イメージを使用すると、コントラストが強く見栄えのよいライティングを作成できます。 最も明るい部分と最も暗い部分に十分なコントラストがある限り、大きなイメージを使用する必要はありません。 推奨解像度は 400 × 200 です。 低い解像度のイメージを使用すると、処理時間が短くなります。

デフォルト値: " empty "

Number_Layers Integer 作成される輝度レイヤの数を制限します。 レイヤを多数使用すると、処理時間が長くなり、メモリの割り当て量が増大します (推奨する値は 3 から 5 です)。

デフォルト値: 3

AreaHigh 浮動小数 レイヤから抽出する輝度の量を決定します。 高い値はより多くの輝度を表し、結果としてより多くのライトが挿入されることになります。

デフォルト値: 20

LightDistHigh 浮動小数 ライト間の距離(イメージの比率)。 値が低いほど、より多くのライトが挿入されます。

デフォルト値: 40

VBScript の例

'

'	This example demonstrates how to use a PIC file to create a

'	special light rig with several infinite lights. It also shows

'	how to find the light rig in your scene (since the newly-created

'	object is not returned as part of the CreateLightRigFromImage command).

'

'	Note: A number of different strategies are presented here, since there

'	is no "LightRig" filter. You can deploy whichever best suits your needs.

'

'-----------------------------------------

'	CREATING THE LIGHT RIG

'

NewScene , false

' Create a couple of nulls (just to make it interesting)

ActiveSceneRoot.AddNull "Danny"

ActiveSceneRoot.AddNull "Fanny"

' For more sport, add an infinite type light rig using the object model

ActiveSceneRoot.AddLightRig "Infinite", "Almighty"

' Create the light rig from one of the sample image PIC files

CreateLightRigFromImage InstallationPath( siFactoryPath ) _

	& "\Data\XSI_SAMPLES\Pictures\xsilogo.pic", 3, 20, 40

'-----------------------------------------

'	SEARCHING AMONGST THE NULLS

'

' First, get a collection of nulls just for comparison

Set oNullList = ActiveSceneRoot.FindChildren( , siNullPrimType )

showCollectionInfo oNullList

'OUTPUT:

'INFO : "-----------------"

'INFO : "Found 3 rig(s) in this collection:"

'INFO : "	Danny"

'INFO : "	Fanny"

'INFO : "	LightRig"

' Or we can build a collection of light rigs based on which nulls have lights

' for children (because presumably only light rigs will have lights for children)

Set oLRColl = CreateObject( "XSI.Collection" )

oLRColl.SetAsText buildLRCollFromNulls( ActiveSceneRoot.FindChildren( , siNullPrimType ) )

showCollectionInfo oLRColl

'OUTPUT:

'INFO : "-----------------"

'INFO : "Found 1 rig(s) in this collection:"

'INFO : "	LightRig"

' Or we can filter the oNullList collection or use the collection Filter on the whole 

' scene by restricting our list to only nulls that contain 'rig' in their name 

Set oNullList = oNullList.Filter( siNullPrimType,, "*rig*" )

showCollectionInfo oNullList

'OUTPUT:

'INFO : "-----------------"

'INFO : "Found 1 rig(s) in this collection:"

'INFO : "	LightRig"

'-----------------------------------------

'	LOOKING BY NAME

'

Set oRigs = ActiveSceneRoot.Children.Filter( siNullPrimType,, "*rig*" )

showCollectionInfo oRigs 

' Now look for LightRig objects under the scene root 

Set oLRigs = ActiveSceneRoot.FindChildren( "LightRig" )

showCollectionInfo oLRigs

'OUTPUT:

'INFO : "-----------------"

'INFO : "Found 1 rig(s) in this collection:"

'INFO : "	LightRig"

'-----------------------------------------

'	FINDING THE WRONG LIGHT RIG

'

' What about the other light rig in the scene? We can get all the lights in

' the scene, find their parents and add each one with the "LightRig" typename

' to a new collection

Set oLights = ActiveSceneRoot.FindChildren( , , siLightPrimitiveFamily )

Set oLRColl = CreateObject( "XSI.Collection" )

oLRColl.SetAsText buildLRCollFromLights( oLights )

showCollectionInfo oLRColl



'-----------------------------------------

'	HELPER FUNCTIONS

'

function showCollectionInfo( in_coll )

	If TypeName( in_coll ) <> "Nothing" _

	   AND in_coll.Count > 0 Then

		LogMessage "-----------------"

		LogMessage "Found " & in_coll.Count & " rig(s) in this collection:"

		For Each mbr In in_coll

			LogMessage vbTab & mbr.FullName

		Next

	Else

		LogMessage "None found."

	End If

end function

function buildLRCollFromLights( in_light_coll )

	If in_light_coll.Count > 0 Then

		Set oCLRColl = CreateObject( "XSI.Collection" )

		For Each mbr In in_light_coll

			' This makes sure we add only true LightRig objects, not the 

			' ones we created with the CreateLightRigFromImage command, 

			' but with the X3DObject.AddLightRig method

			If TypeName( mbr.Parent ) = "LightRig" Then

				oCLRColl.Add mbr.Parent

			End If

		Next

	Else

		LogMessage "Specified collection is empty."

	End If

	buildLRCollFromLights = oCLRColl

end function

function buildLRCollFromNulls( in_null_coll )

	If in_null_coll.Count > 0 Then

		Set oCLRColl = CreateObject( "XSI.Collection" )

		For Each mbr In in_null_coll

			' This looks for a light amongst the children of the null in

			' the current collection, assuming that only nulls that are 

			' light rigs have lights for children

			If mbr.Children.Filter( , siLightPrimitiveFamily ).Count > 0 Then

				oCLRColl.Add mbr

			End If

		Next

	Else

		LogMessage "Specified collection is empty."

	End If

	buildLRCollFromNulls = oCLRColl

end function

関連項目

CreateImageBasedLightingPass X3DObject.AddLightRig