X3DObject.Materials

導入

v4.0

詳細

クラスタおよびサブサーフェイス上のオブジェクトなど、X3DObject のすべての Material オブジェクトを含む MaterialCollection を戻します。

C#構文

// get accessor

MaterialCollection rtn = X3DObject.Materials;

JScript の例

/* 

	This example demonstrates how to access material on an object by first creating the object, then

	adding a constant and lambert shader, and then enumerating the materials collection for that 

	object to 'find' the newly applied materials.

*/

// Set up the scene with the new object

NewScene( null, false );

var oRoot = Application.ActiveProject.ActiveScene.Root;

var oObject = oRoot.AddGeometry( "Cylinder", "MeshSurface" );

// Add the materials

ApplyShader( "Material\\Constant", oObject );

BlendInTextureLayers( "Image", oObject );

SelectGeometryComponents( oObject + ".poly[14,15]" );

ApplyShader( "Material\\Lambert" );

// Loop through the collection of materials

var e = new Enumerator(oObject.Materials);

for ( ; !e.atEnd(); e.moveNext() ) {

	var oMat = e.item();

	Application.LogMessage( "Found " + oMat );

}

// ---------- OUTPUT ---------- 

//INFO : "Found cylinder.Material"

//INFO : "Found cylinder.polymsh.cls.Polygon.Material1"