頂点カラーへのアクセス

 
 
 

頂点カラーは Geometry オブジェクトから取得し、設定できます。VertexColors プロパティを使用し、頂点カラーを列挙します。

例: 頂点カラーの追加と検索

この例では、メッシュ球体上のローカル マテリアルをセットアップし、頂点カラーを追加し、次に頂点カラーを検索します。

' Create a new scene with a sphere
NewScene , false
CreatePrim "Sphere", "MeshSurface"

' Get the selected elements (ie., the sphere)
if Selection.Count = 0 then
	LogMessage "Nothing selected", siError
else
	set oSelectedObjects = Selection

	' Get selected oMeshes from selection list
	set oMeshes = SIFilter(oSelectedObjects, "polygon_mesh", true, siQuickSearch)

	if oMeshes.Count < 1 then
		LogMessage "No polygon oMeshes selected", siError
	end if

	' Add 4 vertex color properties to each mesh
	for i = 0 to oSelectedObjects.Count - 1
		' Get current mesh (type : "polyMsh")
		set oMesh = oSelectedObjects(i)

		' Get obj material
		set oMaterial = oMesh.Material

		' If material is not local add one
		if oMaterial.IsA(siSharedPSet) then
			set oMaterial = oMesh.AddMaterial
		end if

		' Get polygon mesh geometry
		set oPolyGeometry = oMesh.ActivePrimitive.Geometry

		for j = 0 to 3
			oPolyGeometry.AddVertexColor
		next
	next

	' List all vertex colors installed on polygon oMeshes
	for i = 0 to oSelectedObjects.Count - 1
		' Get current mesh (type : "polyMsh")
		set oMesh = oSelectedObjects(i)

		' Get polygon mesh geometry
		set oPolyGeometry = oMesh.ActivePrimitive.Geometry

		set oVertexColors = oPolyGeometry.VertexColors
		LogMessage oVertexColors.Count

		for j = 0 to oVertexColors.Count - 1
			set oVtxColor = oVertexColors(j)
			LogMessage oVtxColor.FullName
		next
	next
end if

' Output of above script:
'INFO : "4"
'INFO : "sphere.polymsh.cls.UV_Cluster_AUTO.Vertex_Color"
'INFO : "sphere.polymsh.cls.UV_Cluster_AUTO.Vertex_Color1"
'INFO : "sphere.polymsh.cls.UV_Cluster_AUTO.Vertex_Color2"
'INFO : "sphere.polymsh.cls.UV_Cluster_AUTO.Vertex_Color3"