face

ポリゴンメッシュ形状の一つの面の操作に使用する。


xshade
shape
face

メソッド一覧

flip 法線の向きを反転する
get_face_uv 面のUVを返す
get_vertex_color 面の頂点カラーを返す
remove 面を削除する
set_face_uv 面のUVを設定する
set_vertex_color 面の頂点カラーを設定する

プロパティ一覧

active 選択状態
active_order 選択した順番の番号
distance_uv 距離UV値のリスト
has_uv uv値を持っているかどうか
normals 面の法線
number_of_vertices 面を構成する頂点の数
parameter_uv パラメータUV値のリスト
shading_normals 自動設定された面の法線
sub_surface_index サブサーフェスオブジェクトのインデックス
vertex_indices 面を構成する頂点番号のタプル




xshade.scene().active_shape().face(0)(選択形状の面の取得)のように面を取得して使用する。

メソッド詳細

flip

法線の向きを反転する。

xshade.scene().active_shape().face(0).flip()

get_face_uv

面のUVを返す。
引数 :
  int : UV層番号
引数 :
  int : 面を構成する頂点番号

#UV1(距離補正)の1番の頂点のUVを出力する
print xshade.scene().active_shape().face(0).get_face_uv(0,1)

get_vertex_color

面の頂点カラーを返す。
引数 :
  int : 頂点カラー層番号
引数 :
  int : 面を構成する頂点番号

#頂点カラー1の0番の頂点の頂点カラーを出力する
print xshade.scene().active_shape().face(0).get_vertex_color(0,0)

remove

面を削除する。

xshade.scene().active_shape().face(0).remove()

set_face_uv

面のUVを設定する。
引数 :
  int : UV層番号
引数 :
  int : 面を構成する頂点番号
引数 :
  float2 : UV値

#UV1(距離補正)の0番の頂点にUV値[0.5, 0.5]を設定する
xshade.scene().active_shape().face(0).set_face_uv(0,0, [0.5, 0.5])

set_vertex_color

面の頂点カラーを設定する。
引数 :
  int : 頂点カラー層番号
引数 :
  int : 面を構成する頂点番号
引数 :
  float4 : 頂点カラー(RGBA)

#頂点カラー1の0番の頂点にグレー[0.5, 0.5, 0.5, 1.0]を設定する
xshade.scene().active_shape().face(0).set_vertex_color(0,0, [0.5, 0.5, 0.5, 1.0])

プロパティ詳細

active

選択状態。

  • 取得
  • 設定

型 :
  bool
設定する場合、図面か形状を更新しないと変更がすぐに反映されない。

#0番の面を選択状態にして形状を更新する
xshade.scene().active_shape().face(0).active = True
xshade.scene().active_shape().update()

active_order

選択した順番の番号。

  • 取得
  • 設定

型 :
  int

print xshade.scene().active_shape().face(0).active_order

distance_uv

距離UV値のリスト。

  • 取得
  • 設定

型 :
  float2のタプル/リストが頂点数あるタプル/リスト
面の頂点に割り当てられている距離UV値のリスト。
ポリゴンメッシュ形状が自由曲面から変換されて生成されたものの場合、元の自由曲面のu-v方向の幾何的距離を正規化した値が初期値として設定されている。

print xshade.scene().active_shape().face(0).distance_uv

has_uv

uv値を持っているかどうか。

  • 取得
  • 設定

型 :
  bool

print xshade.scene().active_shape().face(0).has_uv

normals

面の法線

  • 取得
  • 設定

型 :
  float3 : 面を構成する頂点の法線のタプル
設定しない場合は空のタプルが返る。
面を構成する頂点数と同じ数の法線の配列を設定すると、以後normalsで呼び出す事ができるようになる。
法線の値は任意のものか polygon_meshsetup_normal で自動設定した値を shading_normalsvertexnormal で取得して設定する。

#0番の面に法線を設定して出力する
#選択形状に法線を設定する
xshade.scene().active_shape().setup_normal()
#0番の面を構成する頂点番号のタプルを得る
nface = 0
v_index = xshade.scene().active_shape().face(nface).vertex_indices
#面を構成する頂点の法線を配列にまとめる
nl_normals = []
for i in v_index:
	nl_normals.append(xshade.scene().active_shape().vertex(i).normal)
#法線の配列を0番の面に設定する
xshade.scene().active_shape().face(nface).normals = nl_normals
#設定した値を出力して確認する
print xshade.scene().active_shape().face(nface).normals

number_of_vertices

面を構成する頂点の数。

  • 取得
  • 設定

型 :
  int

print xshade.scene().active_shape().face(0).number_of_vertices

parameter_uv

パラメータUV値のリスト。

  • 取得
  • 設定

型 :
  float2のタプル/リストが頂点数あるタプル/リスト
面の頂点に割り当てられているパラメータUV値のリスト。
ポリゴンメッシュ形状が自由曲面から変換されて生成されたものの場合、元の自由曲面のu-vパラメータ値が初期値として設定されている。

print xshade.scene().active_shape().face(0).parameter_uv

shading_normals

自動設定された面の法線

  • 取得

型 :
  float3 : 面を構成する頂点の法線のタプル
polygon_meshsetup_normal で計算された法線ベクトルを返す。
明示的に法線ベクトルの値が設定されていると、normals と同じ値を返す。

#面に法線を設定して出力する
xshade.scene().active_shape().setup_normal()
for i in range(xshade.scene().active_shape().number_of_faces):
	print xshade.scene().active_shape().face(i).shading_normals

sub_surface_index

サブサーフェスオブジェクトのインデックス。

  • 取得
  • 設定

型 :
  int
インデックス値で指定されたサブオブジェクトの表面材質属性がこの面に割り当てられる。
デフォルト値は-1で、割り当てられていない状態。

print xshade.scene().active_shape().face(0).sub_surface_index

vertex_indices

面を構成する頂点番号のタプル。

  • 取得
  • 設定

型 :
  intのタプル

print xshade.scene().active_shape().face(0).vertex_indices