メニュー 閉じる

077. p5.jsで3Dシューティングゲーム用の戦闘機をモデリングしてみる

といっても単純にBoxとCylinderの組み合わせ・・・。

http://www.velvet-number.com/p5_test/test054/

function setup () {

	pixelDensity (displayDensity ());
	createCanvas (windowWidth, windowHeight, WEBGL);
	colorMode (RGB, 256);
	background (0);

}

function draw () {

	background (0);

	ambientLight (10, 120, 40);
  	pointLight (255, 0, 0, 2000.0, 0.0, 2000.0);
  	pointLight (255, 0, 0, -2000.0, 0.0, -2000.0);
  	pointLight (0, 255, 0, 0.0, 2000.0, 2000.0);
  	pointLight (0, 255, 0, 0.0, -2000.0, -2000.0);
  	pointLight (255, 0, 0, 2000.0, 0.0, 2000.0);
  	pointLight (255, 0, 0, -2000.0, 0.0, -2000.0);
  	pointLight (0, 255, 0, 0.0, 2000.0, 2000.0);
  	pointLight (0, 255, 0, 0.0, -2000.0, -2000.0);

  	camera (0.0, 0.0, -250.0,
			0.0, 0.0, 0.0,
			0.0, 1.0, 0.0);

	translate (0.0, 0.0, 0.0);
	rotateX (0.4);
	rotateY (frameCount / 100.0);

	stroke (0);
	strokeWeight (0.2);

	push ();
	translate (0.0, 0.0, 0.0);
	box (80.0, 10.0, 100.0);
	pop ();

	push ();
	translate (0.0, 0.0, -60.0);
	box (40.0, 5.0, 100.0);
	pop ();

	push ();
	translate (-60.0, 0.0, 0.0);
	box (40.0, 5.0, 40.0);
	pop ();

	push ();
	translate (60.0, 0.0, 0.0);
	box (40.0, 5.0, 40.0);
	pop ();

	push ();
	translate (-60.0, .0, -20.0);
	rotateX (PI / 2.0);
	cylinder (2.0, 40.0);
	pop ();

	push ();
	translate (60.0, .0, -20.0);
	rotateX (PI / 2.0);
	cylinder (2.0, 40.0);
	pop ();

	push ();
	translate (-30.0, -5.0, 50.0);
	box (4.0, 20.0, 40.0);
	pop ();

	push ();
	translate (30.0, -5.0, 50.0);
	box (4.0, 20.0, 40.0);
	pop ();

}

 

Posted in p5.js , processing