'
' This example shows how to find all image clips associated with a Material
'
set oObj = BuildDemoScene
set oImageClips = oObj.Material.ImageClips
for each oImageClip in oImageClips
Application.LogMessage oImageClip.FullName
next
'Example output:
'INFO : sphere.Material.Phong.Image.jaiqua_face_jpg
'INFO : sphere.Material.Phong.Color2scalar.Image1.ehair_08_jpg
' Create a little sample render tree
' It has no interesting visual appearance but is a render tree with
' various shaders and two images so that we can demonstrate the
' FindImageClips routine
'
' Return value is the X3DObject
'
function BuildDemoScene
NewScene ,false
ImageFile1 = XSIUtils.BuildPath( Application.InstallationPath(siFactoryPath), _
"Data", _
"XSI_SAMPLES",_
"Pictures",_
"jaiqua_face.jpg" )
ImageFile2 = XSIUtils.BuildPath( Application.InstallationPath(siFactoryPath), _
"Data", _
"XSI_SAMPLES",_
"Pictures",_
"ehair_08.jpg" )
NewScene , false
set oObj = ActiveSceneRoot.AddGeometry( "Sphere", "MeshSurface" )
oObj.AddMaterial "Phong"
dim oPhongShader, oAmbientParam, oDiffuseParam, oShinyParam
set oPhongShader = oObj.Material.Shaders(0)
set oAmbientParam = oPhongShader.Parameters( "ambient" )
set oDiffuseParam = oPhongShader.Parameters( "diffuse" )
set oShinyParam= oPhongShader.Parameters( "shiny" )
dim oImageClip1, oImageClip2
SICreateImageClip ImageFile1, ,oImageClip1
SICreateImageClip ImageFile2, ,oImageClip2
dim oImageNode1,oImageNode2
set oImageNode1 = oAmbientParam.connectfrompreset("Image", siTextureShaderFamily)
oDiffuseParam.Connect( oImageNode1 )
oImageNode1.Parameters( "tex" ).Connect( oImageClip1 )
set oImageNode2 = oShinyParam.connectfrompreset("Image", siTextureShaderFamily)
oImageNode2.Parameters( "tex" ).Connect( oImageClip2 )
set BuildDemoScene = oObj
end function |