ページ 11

【DXライブラリ】【3D】ポリゴンの端の表示が崩れる

Posted: 2012年9月01日(土) 16:35
by みけCAT
環境は
Dev-C++5.2.0.3(gcc4.7.0)
Windows Vista SP2 32ビット
Mobile Intel(R) 965 Express Chipset Family
Intel(R) Core(TM)2 Duo CPU T8100 @ 2.10GHz (2 CPUs)
DXライブラリ v3.08c
です。

自作の3D表示プログラムをDXライブラリに移植してみたのですが、
ポリゴンの端の表示が乱れます。
画像あり、なしともに乱れます。
具体的には、この画像のように、隣のポリゴンの色や画像がはみ出してきます。
dxlib_polygon_error.png
おかしい表示です。
dxlib_polygon_error.png (58.02 KiB) 閲覧数: 2321 回
これは直せるでしょうか?
ライトの計算はオフ、Zバッファは有効です。

ポリゴンを描画する関数はこのようになっています。
上が画像を貼り付ける関数、下がベタ塗りをする関数です。

コード:

void draw3dHenkan(
		int x1,int y1,int z1,
		int x2,int y2,int z2,
		int x3,int y3,int z3,
		int isUpper,int bmp) {
	y1=-y1;y2=-y2;y3=-y3;
	VERTEX3D vertex[3]={};
	vertex[0].pos=VGet(x1,y1,z1);
	vertex[1].pos=VGet(x2,y2,z2);
	vertex[2].pos=VGet(x3,y3,z3);
	vertex[0].dif=GetColorU8(255,255,255,255);
	vertex[1].dif=GetColorU8(255,255,255,255);
	vertex[2].dif=GetColorU8(255,255,255,255);
	vertex[0].u=(isUpper?0:1);
	vertex[0].v=(isUpper?0:1);
	vertex[1].u=1;
	vertex[1].v=0;
	vertex[2].u=0;
	vertex[2].v=1;
	DrawPolygon3D(vertex,1,bmp,FALSE);
}

void draw3dColor(
		int x1,int y1,int z1,
		int x2,int y2,int z2,
		int x3,int y3,int z3,
		int r,int g,int b) {
	y1=-y1;y2=-y2;y3=-y3;
	VERTEX3D vertex[3]={};
	vertex[0].pos=VGet(x1,y1,z1);
	vertex[1].pos=VGet(x2,y2,z2);
	vertex[2].pos=VGet(x3,y3,z3);
	vertex[0].dif=GetColorU8(r,g,b,255);
	vertex[1].dif=GetColorU8(r,g,b,255);
	vertex[2].dif=GetColorU8(r,g,b,255);
	DrawPolygon3D(vertex,1,DX_NONE_GRAPH,FALSE);
}
移植元のプロジェクトとDXライブラリを使用したプロジェクトを添付します。
よろしくお願いします。

なお、このDXライブラリを使用したプロジェクトではサイコロの表示が乱れていますが、
このことについては本家掲示板で質問させていただきました。
http://hpcgi2.nifty.com/natupaji/bbs/pa ... ew&no=2748

Re: 【DXライブラリ】【3D】ポリゴンの端の表示が崩れる

Posted: 2012年9月02日(日) 08:28
by みけCAT
DXライブラリ質問掲示板の方で回答をいただきました。
http://hpcgi2.nifty.com/natupaji/bbs/pa ... ew&no=2748

コード:

SetCameraNearFar(0.1,1000);

コード:

SetCameraNearFar(10,1000);
にすることで解決しました。