ここをキャンプ地とするブログ

いきあたりばったり

Skyboxな背景出た

引き続きこちらのチュートリアルを素直にパクり中。

http://www.thehazymind.com/XNAEngine.htm


背景が出るとこまででけた。

f:id:Kuna:20070302005737j:image

真ん中の空条グルーミーはTexturedQuadオブジェクト(ただのテクスチャ付き板ポリ)。

テクスチャ自体はネットの拾い物。作った人GJ。


背景の画像はこちらから頂きました。

http://www.hazelwhorley.com/textures.html

The above texture packs are for non-commercial purposes only. You're free to use and modify them otherwise.

非商用でっす!ありがたく頂戴いたしまっす!


そいやエンジンのチュートリアル、カメラのとこで間違い発見。

http://www.thehazymind.com/archives/2006/10/moving_cameras.htm の始めのコードで、

public void Revolve(Vector3 target, Vector3 axis, float angle) {
	Rotate(axis, angle);

	axis = Vector3.Transform(axis, Matrix.CreateFromQuaternion(myRotation));
	Quaternion rotate = Quaternion.CreateFromAxisAngle(axis, angle);
	myPosition = Vector3.Transform(
		target - myPosition, Matrix.CreateFromQuaternion(rotate)
	);

	Update();
}

のmyPositionの計算が変です。

myPosition = Vector3.Transform(
		myPosition - target, Matrix.CreateFromQuaternion(rotate)
	);
myPostion += target

が正解ではないかと!

チュートリアルはたまたま

  • targetが原点
  • 1フレに2回Revolve()が呼ばれる

から大丈夫だけど。

どっちかの条件が外れたらダメなはず。