// テクスチャ付きポリゴンの描画テスト // 四角形が三角形ポリゴン2つで描画されてるのが分かる // Processing.js で画像ファイルを読み込みたい時は以下の指定が必要 /* @pjs preload="uvmap.png"; */ PImage img; void setup() { size(640, 480, P3D); img = loadImage("uvmap.png"); } void draw() { background(0); translate(width / 2, height / 2); beginShape(); // 図形描画開始 texture(img); // テクスチャを指定 // 各頂点の位置と、対応するテクスチャ座標を指定 vertex(-300, -100, 0, 0, 0); vertex(-100, -100, 0, img.width, 0); vertex(-100, 100, 0, img.width, img.height); vertex(-300, 100, 0, 0, img.height); endShape(); beginShape(); texture(img); vertex(0, -100, 0, 0, 0); vertex(300, -100, 0, img.width, 0); vertex(250, 100, 0, img.width, img.height); vertex(100, 100, 0, 0, img.height); endShape(); }