質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
C++

C++はC言語をもとにしてつくられた最もよく使われるマルチパラダイムプログラミング言語の1つです。オブジェクト指向、ジェネリック、命令型など広く対応しており、多目的に使用されています。

3DCG

コンピュータの演算により、3次元空間の仮想物体を、2次元平面上で表現する手法である。

DXライブラリ

DXライブラリとは、DirectXを使ったWindowsソフトの開発に必ず付いて回るDirectXやWindows関連のプログラムを使い易くまとめた形で利用できるようにしたC++言語用のゲームライブラリです。

Q&A

0回答

778閲覧

板ポリと板ポリの間に隙間ができる原因と対処法が知りたい。

退会済みユーザー

退会済みユーザー

総合スコア0

C++

C++はC言語をもとにしてつくられた最もよく使われるマルチパラダイムプログラミング言語の1つです。オブジェクト指向、ジェネリック、命令型など広く対応しており、多目的に使用されています。

3DCG

コンピュータの演算により、3次元空間の仮想物体を、2次元平面上で表現する手法である。

DXライブラリ

DXライブラリとは、DirectXを使ったWindowsソフトの開発に必ず付いて回るDirectXやWindows関連のプログラムを使い易くまとめた形で利用できるようにしたC++言語用のゲームライブラリです。

0グッド

0クリップ

投稿2020/04/03 01:59

編集2020/04/03 05:52

提示画像の板ポリと板ポリの間の画像の真ん中に黒い線がりますがポリゴンの隙間だと思うのですがこれは何が原因で何をすればいいのでしょうか?dxlib 公式掲示板を見ましたがわからないので質問しました。

やったこと
背景を追加して隙間なのかどうかを判定 違いました。
ボタンでテクスチャを付け消ししました 違いました。

イメージ説明
イメージ説明

Game::Game() { SetUseLighting(true); SetUseZBuffer3D(true); SetWriteZBuffer3D(true); /*手前*/ Vertex[0].pos = VGet(-RANGE, RANGE, 10); Vertex[0].norm = VGet(0.0f, 0.0f, -1.0f); Vertex[0].dif = color_dif; Vertex[0].spc = color_spc; Vertex[0].u = 0.0f; Vertex[0].v = 0.0f; Vertex[0].su = 0.0f; Vertex[0].sv = 0.0f; Vertex[1].pos = VGet(RANGE, RANGE, 10); Vertex[1].norm = VGet(0.0f, 0.0f, -1.0f); Vertex[1].dif = color_dif; Vertex[1].spc = color_spc; Vertex[1].u = 1.0f; Vertex[1].v = 0.0f; Vertex[1].su = 0.0f; Vertex[1].sv = 0.0f; Vertex[2].pos = VGet(-RANGE, -RANGE, 10); Vertex[2].norm = VGet(0.0f, 0.0f, -1.0f); Vertex[2].dif = color_dif; Vertex[2].spc = color_spc; Vertex[2].u = 0.0f; Vertex[2].v = 1.0f; Vertex[2].su = 0.0f; Vertex[2].sv = 0.0f; Vertex[3].pos = VGet(RANGE, -RANGE, 10); Vertex[3].norm = VGet(0.0f, 0.0f, -1.0f); Vertex[3].dif = color_dif; Vertex[3].spc = color_spc; Vertex[3].u = 1.0f; Vertex[3].v = 1.0f; Vertex[3].su = 0.0f; Vertex[3].sv = 0.0f; /*奥*/ Vertex[4].pos = VGet(-RANGE, RANGE, 10 + RANGE); Vertex[4].norm = VGet(0.0f, 0.0f, -1.0f); Vertex[4].dif = color_dif; Vertex[4].spc = color_spc; Vertex[4].u = 0.0f; Vertex[4].v = 0.0f; Vertex[4].su = 0.0f; Vertex[4].sv = 0.0f; Vertex[5].pos = VGet(RANGE, RANGE, 10 + RANGE); Vertex[5].norm = VGet(0.0f, 0.0f, -1.0f); Vertex[5].dif = color_dif; Vertex[5].spc = color_spc; Vertex[5].u = 1.0f; Vertex[5].v = 0.0f; Vertex[5].su = 0.0f; Vertex[5].sv = 0.0f; Vertex[6].pos = VGet(-RANGE, -RANGE, 10 + RANGE); Vertex[6].norm = VGet(0.0f, 0.0f, -1.0f); Vertex[6].dif = color_dif; Vertex[6].spc = color_spc; Vertex[6].u = 0.0f; Vertex[6].v = 1.0f; Vertex[6].su = 0.0f; Vertex[6].sv = 0.0f; Vertex[7].pos = VGet(RANGE, -RANGE, 10 + RANGE); Vertex[7].norm = VGet(0.0f, 0.0f, -1.0f); Vertex[7].dif = color_dif; Vertex[7].spc = color_spc; Vertex[7].u = 1.0f; Vertex[7].v = 1.0f; Vertex[7].su = 0.0f; Vertex[7].sv = 0.0f; #define GROUND_Z 200 #define GROUND_X 200 /*地面 ポリゴン 地面インデックスを割愛*/ /*手前*/ Index[0][0] = 0; Index[0][1] = 1; Index[0][2] = 2; Index[0][3] = 1; Index[0][4] = 2; Index[0][5] = 3; /*奥*/ Index[1][0] = 4; Index[1][1] = 5; Index[1][2] = 6; Index[1][3] = 6; Index[1][4] = 5; Index[1][5] = 7; /*左*/ Index[2][0] = 0; Index[2][1] = 4; Index[2][2] = 2; Index[2][3] = 4; Index[2][4] = 2; Index[2][5] = 6; /*右*/ Index[3][0] = 1; Index[3][1] = 5; Index[3][2] = 7; Index[3][3] = 1; Index[3][4] = 3; Index[3][5] = 7; /*上*/ Index[4][0] = 0; Index[4][1] = 4; Index[4][2] = 5; Index[4][3] = 0; Index[4][4] = 1; Index[4][5] = 5; /*下*/ Index[5][0] = 6; Index[5][1] = 7; Index[5][2] = 2; Index[5][3] = 3; Index[5][4] = 7; Index[5][5] = 2; } /* (x,y)の点を(mx,my)を中心にang角回転する */ void rotate(float* x, float* y, const float ang, const float mx, const float my) { const float ox = *x - mx, oy = *y - my; *x = (ox * cos(ang)) + (oy * sin(ang)); *y = (-ox * sin(ang)) + (oy * cos(ang)); *x += mx; *y += my; } /*X軸回転*/ void rotate_X(float *y,float *z,const float ang,const float my,const float mz) { const float oy = *y - my; const float oz = *z - mz; *y = (oy * cos(ang)) + (oz * sin(ang)); *z = (-oy * sin(ang)) + (oz * cos(ang)); *y += my; *z += mz; } void Game::Update() { /*カメラ回転*/ if (Input::keyboard(KEY_INPUT_LEFT) > 0) { rotate(&cameraX, &cameraZ, +ROTATE_SPEED, targetX, targetZ); } else if (Input::keyboard(KEY_INPUT_RIGHT) > 0) { rotate(&cameraX, &cameraZ, -ROTATE_SPEED, targetX, targetZ); } else if (Input::keyboard(KEY_INPUT_UP) > 0) { rotate_X(&cameraY, &cameraZ, -ROTATE_SPEED, targetY, targetZ); } else if (Input::keyboard(KEY_INPUT_DOWN) > 0) { rotate_X(&cameraY, &cameraZ, +ROTATE_SPEED, targetY, targetZ); } if (Input::keyboard(KEY_INPUT_W) > 0) { cameraZ += -4; } else if (Input::keyboard(KEY_INPUT_S) > 0) { y -= 2; } /*色 変更*/ if(Input::keyboard(KEY_INPUT_SPACE) == 1) { ModeChange = !ModeChange; } /* false spcカラーを変更*/ if (Input::keyboard(KEY_INPUT_Z) > 0 && ModeChange == false) { color_spc.r += -1; color_spc.g += -1; color_spc.b += -1; } else if (Input::keyboard(KEY_INPUT_X) > 0 && ModeChange == false) { color_spc.r += 1; color_spc.g += 1; color_spc.b += 1; /*true difカラー変更*/ }else if (Input::keyboard(KEY_INPUT_Z) > 0 && ModeChange == true) { color_dif.r += -1; color_dif.g += -1; color_dif.b += -1; } else if (Input::keyboard(KEY_INPUT_X) > 0 && ModeChange == true) { color_dif.r += 1; color_dif.g += 1; color_dif.b += 1; } if (Input::keyboard(KEY_INPUT_F1) == 1) { TextureMode = !TextureMode; } const int num = 4; } VECTOR v; //45,48 void Game::DrawUpdate() { SetCameraPositionAndTarget_UpVecY(VGet(cameraX, cameraY, cameraZ), VGet(targetX, targetY, targetZ)); for(int i = 0; i< 8; i++) { Vertex[i].dif = color_dif; Vertex[i].spc = color_spc; } int handle = LoadGraph("assets/resource/texturePos.png",false); for(int i =0 ;i < 6; i++){ switch( i ) { case 0: { Vertex[ 0 ].u = 0.0f; Vertex[ 0 ].v = 0.0f; Vertex[ 1 ].u = 1.0f; Vertex[ 1 ].v = 0.0f; Vertex[ 2 ].u = 0.0f; Vertex[ 2 ].v = 1.0f; Vertex[ 3 ].u = 1.0f; Vertex[ 3 ].v = 1.0f; Vertex[ 4 ].u = 1.0f; Vertex[ 4 ].v = 1.0f; Vertex[ 5 ].u = 0.0f; Vertex[ 5 ].v = 0.0f; Vertex[ 6 ].u = 0.0f; Vertex[ 6 ].v = 0.0f; Vertex[ 7 ].u = 0.0f; Vertex[ 7 ].v = 0.0f; } break; case 1: { Vertex[0].u = 0.0f; Vertex[0].v = 0.0f; Vertex[1].u = 1.0f; Vertex[1].v = 0.0f; Vertex[2].u = 0.0f; Vertex[2].v = 1.0f; Vertex[3].u = 0.0f; Vertex[3].v = 0.0f; Vertex[4].u = 0.0f; Vertex[4].v = 0.0f; Vertex[5].u = 1.0f; Vertex[5].v = 0.0f; Vertex[6].u = 0.0f; Vertex[6].v = 1.0f; Vertex[7].u = 1.0f; Vertex[7].v = 1.0f; } break; case 2: { Vertex[0].u = 1.0f; Vertex[0].v = 0.0f; Vertex[1].u = 1.0f; Vertex[1].v = 0.0f; Vertex[2].u = 1.0f; Vertex[2].v = 1.0f; Vertex[3].u = 0.0f; Vertex[3].v = 0.0f; Vertex[4].u = 0.0f; Vertex[4].v = 0.0f; Vertex[5].u = 0.0f; Vertex[5].v = 1.0f; Vertex[6].u = 0.0f; Vertex[6].v = 1.0f; Vertex[7].u = 1.0f; Vertex[7].v = 1.0f; } break; /*右*/ case 3: { Vertex[1].u = 0.0f; Vertex[1].v = 0.0f; Vertex[3].u = 0.0f; Vertex[3].v = 1.0f; Vertex[4].u = 0.0f; Vertex[4].v = 0.0f; Vertex[5].u = 1.0f; Vertex[5].v = 0.0f; Vertex[6].u = 0.0f; Vertex[6].v = 1.0f; Vertex[7].u = 1.0f; Vertex[7].v = 1.0f; } break; /*上*/ case 4: { Vertex[0].u = 0.0f; Vertex[0].v = 0.0f; Vertex[1].u = 0.0f; Vertex[1].v = 1.0f; Vertex[4].u = 1.0f; Vertex[4].v = 0.0f; Vertex[5].u = 1.0f; Vertex[5].v = 1.0f; } break; /*下*/ case 5: { Vertex[2].u = 0.0f; Vertex[2].v = 1.0f; Vertex[3].u = 1.0f; Vertex[3].v = 1.0f; Vertex[6].u = 0.0f; Vertex[6].v = 0.0f; Vertex[7].u = 1.0f; Vertex[7].v = 0.0f; } break; } if(TextureMode == true){ DrawPolygonIndexed3D(Vertex, 8, Index[i], 2, handle, false); }else{ DrawPolygonIndexed3D(Vertex, 8, Index[i], 2, DX_NONE_GRAPH, false); } } DrawPolygonIndexed3D(Ground_Vertex,4,Ground_Index,6,handle,false); // cameraY += -1; DrawFormatString(0, 0, GetColor(255, 255, 255), "カメラ座標 x: %.2f , y: %.2f , z:%.2f ", cameraX,cameraY,cameraZ); // DrawFormatString(0, 40, Get color;(255, 255, 255), " test x: %.2f z: %.2f", xx, zz); if(ModeChange == false){ DrawFormatString(0, 32 * 5, GetColor(255, 255, 255), "Mode: spc "); DrawFormatString(0, 32 * 1, GetColor(255, 255, 255), "color_spc.r: %d", color_spc.r); DrawFormatString(0, 32 * 2, GetColor(255, 255, 255), "color_spc.g: %d", color_spc.g); DrawFormatString(0, 32 * 3, GetColor(255, 255, 255), "color_spc.b: %d", color_spc.b); }else { DrawFormatString(0, 32 * 5, GetColor(255, 255, 255), "Mode: dif "); DrawFormatString(0, 32 * 1, GetColor(255, 255, 255), "color_dif.r: %d", color_dif.r); DrawFormatString(0, 32 * 2, GetColor(255, 255, 255), "color_dif.g: %d", color_dif.g); DrawFormatString(0, 32 * 3, GetColor(255, 255, 255), "color_dif.b: %d", color_dif.b); } }

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

fana

2020/04/03 02:08

単にそういうテクスチャを貼ったということはありませんか?(テクスチャ無しでも同じ現象になりますか?) 本当に「隙間」なのかどうか,背景色を黒ではない別の色に変えてみたらわからないでしょうか?(例えば背景を青にしたならば,「隙間」があるのであればそこの線も青く見えるハズ)
退会済みユーザー

退会済みユーザー

2020/04/03 02:21 編集

Vertex[1].dif = GetColorU8(20, 100, 200, 0);などとしすべて同じdifにしましたが黒い線が面と面の間にできてしまいます。.norm spcなどこの場合関係あるのでしょうか?ライトは有効です。テクスチャ画像は256,256です。pngです。
takabosoft

2020/04/03 05:08

えーと、fanaさんも提案してくれていますが、テクスチャを剥がしてみるとどうですか?
退会済みユーザー

退会済みユーザー

2020/04/03 05:46

角度によっては黒く映ります。赤色にしてボタンでテクスチャを付け消しましたが違うみたいです
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問