net.minecraft.client.model.ModelRenderer
注意事項
この記事はforge-1.8.9-11.15.1.1722のソースを筆者が記述した時点での拙い知識で解釈したもののメモです。
誤訳や理解不足の可能性を多分に含みます。ご覧になる際はご注意ください。
ModelRenderer
モデルのレンダリングを実際に引き受けているクラス。
基本的には1つのMedelRendererに一つの四角とテクスチャ。
3Dグラフィックに触れたことがないので不明点が多い。
フィールド
public float textureWidth; public float textureHeight;
テクスチャ画像の幅と高さ。単位はピクセル。
private int textureOffsetX; private int textureOffsetY;
テクスチャ画像のうち実際に使用する範囲の始点。単位はピクセル
public float rotationPointX; public float rotationPointY; public float rotationPointZ;
回転処理の始点座標
public float rotateAngleX; public float rotateAngleY; public float rotateAngleZ;
モデルの方向(角度)
private boolean compiled; private int displayList;
OpenGLの機能であるdisplayListとそれ用の描画情報がコンパイル済かのフラグ
public boolean showModel; public boolean isHidden;
名前からして表示非表示の切り替えだと思われるが使いわけ方が不明。
public List<ModelBox> cubeList;
レンダラが持つModelBoxのリスト。基本的に同じテクスチャ画像をオフセット指定で使いまわす。
public List<ModelRenderer> childModels;
子のレンダラ。こちらはModelRendererなのでそれぞれにテクスチャを指定できる。
public final String boxName;
レンダラの名前。
private ModelBase baseModel;
レンダラの親となるモデル。テクスチャのオフセットを得るために使用している模様
public float offsetX; public float offsetY; public float offsetZ;
座標のオフセット。どこを原点にしてのオフセットなのか不明
コンストラクタ
public ModelRenderer(ModelBase model, String boxNameIn) { this.textureWidth = 64.0F; this.textureHeight = 32.0F; this.showModel = true; this.cubeList = Lists.<ModelBox>newArrayList(); this.baseModel = model; model.boxList.add(this); this.boxName = boxNameIn; this.setTextureSize(model.textureWidth, model.textureHeight); }
一番詳細なコンストラクタ。別のコンストラクタはboxNameをnullで転送する。また、このコンストラクタはtexturOffsetを受け取らず、受け取るコンストラクタは別途setTextureOffsetを自分で呼び出す。
メソッド
public void addChild(ModelRenderer renderer)
現在のボックスの回転位置と回転角度を他のボックスへセットする
別のレンダラをこのレンダラと連動するようにする。
public ModelRenderer setTextureOffset(int x, int y)
テクスチャのオフセットのセッター
public void addBox(float p_78790_1_, float p_78790_2_, float p_78790_3_, int width, int height, int depth, float scaleFactor)
テクスチャ付きのボックスを追加する。引数はX,Y,Z,幅、高さ、奥行き、スケール倍率。
唯一コメントのついているaddBox。
他のaddBoxと見比べると、名前指定をするタイプのaddBoxの時は親Modelの持つMapからテクスチャのオフセットを取得してテクスチャを部分使用する。
それ以外はまったく同じテクスチャを使いまわすと思われる。
public void setRotationPoint(float rotationPointXIn, float rotationPointYIn, float rotationPointZIn)
回転処理の中心座標をセットする。