teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

13

提示コードを編集

2020/04/10 02:36

投稿

退会済みユーザー
title CHANGED
@@ -1,1 +1,1 @@
1
- クォータニオンによる中心点を中心にラジアン度カメラを回転する視点移動を実装したい。
1
+ クォータニオンによる中心点を中心にラジアン度カメラを回転する視点移動を実装したい。原点の算出法など
body CHANGED
@@ -1,6 +1,5 @@
1
- 参考サイトなどを見て計算式をプログラムに落とし込んだが何が原因で以下の症状のようなバグでるのかどうしてもわかりません
1
+ 参考サイトなどを見て計算式をプログラムに落とし込んだが何が原因でカメラ注視点を中心に回転しくれないのかわからない”地球を中心に回る月のような月”
2
- rotate();関数の引数は(座標,ラジアン,中心点,回転軸)ようになっています。
3
- "座標"を"中心点"を中心とした"回転軸"に"ラジアン"回転するということを目的としています。
2
+ rotate();関数の引数は(座標,ラジアン,中心点,回転軸)ようになっています。"座標"を"中心点"を中心とした"回転軸"に"ラジアン"回転するということを目的としています。
4
3
 
5
4
 
6
5
 
@@ -27,31 +26,32 @@
27
26
  ```ここに言語を入力
28
27
 
29
28
  /*回転 回転する座標、ラジアン、中心、軸*/
29
+
30
+
31
+ /*回転する座標、ラジアン、中心、軸*/
30
- void Game::rotate(Vector *pos,const float ang, const Vector target,const Vector axis)
32
+ void Game::rotate(Vector *pos,const float ang, const Vector targetV,const Vector axis)
31
33
  {
32
34
 
33
35
  //Quaternion Prev(0, Vector(*x - mx, *y - my, *z - mz));
34
36
 
35
- Quaternion P(0,Vector(pos->x, pos->y, pos->z));//回転させる点
37
+ Quaternion P(0, Vector(pos->x, pos->y, pos->z));//回転させる点
38
+ Quaternion P2(0, Vector(pos->x - targetV.x, pos->y - targetV.y, pos->z - targetV.z));//回転させる点
39
+ Quaternion PP(0, Vector(targetV.x - pos->x, targetV.y - pos->y, targetV.z - pos->z));//回転させる点
40
+ Quaternion PP3(0,Vector(targetV.x , targetV.y , targetV.z ));//回転させる点
36
41
 
42
+ Quaternion Q(cos(ang / 2), Vector( axis.x * sin(ang / 2), axis.y * sin(ang / 2), axis.z * sin(ang / 2)));
43
+ Quaternion R(cos(ang / 2), Vector(-axis.x * sin(ang / 2) , -axis.y * sin(ang / 2), -axis.z * sin(ang / 2)));
44
+
37
- MATRIX t = MGetRotX(ang);//回転させる軸
45
+ Quaternion result = (R * P2) * Q;//順番が大事
38
46
 
39
- VECTOR v;
40
- v.x = -1;
47
+ ofs << "pos.x:" << pos->x << std::endl;
41
- v.y = 0;
48
+ ofs << "pos.y:" << pos->y << std::endl;
42
- v.z = 0;
49
+ ofs << "pos.z:" << pos->z << "\n" << std::endl;
43
50
 
44
-
45
- Quaternion Q(cos(ang / 2), Vector(v.x * sin(ang / 2), v.y * sin(ang / 2), v.z * sin(ang / 2)));
46
- Quaternion R(cos(ang / 2), Vector(-v.x * sin(ang / 2) , -v.y * sin(ang / 2), -v.z * sin(ang / 2)));
47
-
48
- /*
49
51
  ofs << "result.x:" << result.v.x << std::endl;
50
52
  ofs << "result.y:" << result.v.y << std::endl;
51
- ofs<< "result.z:" << result.v.z <<"\n\n\n"<< std::endl;
53
+ ofs << "result.z:" << result.v.z << "\n\n\n" << std::endl;
52
- */
54
+
53
- Quaternion result = R * P * Q;//順番が大事
54
-
55
55
  pos->x = result.v.x;
56
56
  pos->y = result.v.y;
57
57
  pos->z = result.v.z;

12

タイトルを再度編集しました。

2020/04/10 02:36

投稿

退会済みユーザー
title CHANGED
@@ -1,1 +1,1 @@
1
- クォータニオンによる中心点を中心にラジアン度 カメラ回転を実装したい。
1
+ クォータニオンによる中心点を中心にラジアン度カメラ回転する視点移動を実装したい。
body CHANGED
File without changes

11

文章とタイトルを編集しました。

2020/04/07 04:30

投稿

退会済みユーザー
title CHANGED
@@ -1,1 +1,1 @@
1
- クォータニオンによるカメラ回転を実装したい。その時の空間を2Dのように回ってしまう原因とは
1
+ クォータニオンによる中心点を中心にラジアン度 カメラ回転を実装したい。
body CHANGED
@@ -1,16 +1,20 @@
1
1
  参考サイトなどを見て計算式をプログラムに落とし込んだが何が原因で以下の症状のようなバグがでるのかどうしてもわかりません。
2
+ rotate();関数の引数は(座標,ラジアン,中心点,回転軸)ようになっています。
3
+ "座標"を"中心点"を中心とした"回転軸"に"ラジアン"回転するということを目的としています。
2
4
 
3
- 質問1、X軸回転の関数ですがクォータニオンの計算をしてカメラを回転させたいがクォータニオン同士の掛け算やベクトルの外積、内積の計算が正しいのか?
4
5
 
6
+
7
+ 質問1、rotate関数ですがクォータニオンの計算をしてカメラを回転させたいがクォータニオン同士の掛け算や
8
+ ベクトルの外積、内積の計算が正しいのか、注視点はいいのか?
9
+
5
10
  質問2、"回転軸ベクトル"とは何をすれば算出されるのでしょうか?
6
11
 
7
- 質問3.以下の症状が修正できず、何が悪いのかわからない。
8
- 症状は 実行時に上下に動かと見事にクォータニオンしてくれますが左右動いたあとrotate();関数が行されてそ
12
+ 質問3、どうればクォータニオンによる中心点を中心にラジアン度 カメラ回転を装できるか知りたい。
9
- 上下に動かすとその**空間座標?を中心にくるくる回ってしまいます**
10
13
 
11
- やりたいこと **周回軌道のようなモン〇ンのカメラのようなカメラ動作をしてほしい。**
12
14
 
15
+ やりたいこと **周回軌道のようなモン〇ンのような3アクションゲームのカメラのようなカメラ動作をしてほしい。**
13
16
 
17
+
14
18
  ![イメージ説明](7036df702c017099eb73b3deb642844a.png)
15
19
 
16
20
 
@@ -21,13 +25,14 @@
21
25
 
22
26
  以下rotete_x();関数部です。引数にカメラ座標と注視点座標とラジアンを入れて回転させる予定
23
27
  ```ここに言語を入力
28
+
24
- /*X軸回転*/
29
+ /*回転 回転する座標、ラジアン、中心、軸*/
25
- void Game::rotate_X(float *x,float *y,float *z,const float ang, const float mx,const float my,const float mz)
30
+ void Game::rotate(Vector *pos,const float ang, const Vector target,const Vector axis)
26
31
  {
32
+
33
+ //Quaternion Prev(0, Vector(*x - mx, *y - my, *z - mz));
27
34
 
28
- //Quaternion Prev(0, Vector(*x - mx, *y - my, *z - mz));
29
-
30
- Quaternion P(0,Vector(*x, *y, *z));//回転させる点
35
+ Quaternion P(0,Vector(pos->x, pos->y, pos->z));//回転させる点
31
36
 
32
37
  MATRIX t = MGetRotX(ang);//回転させる軸
33
38
 
@@ -47,50 +52,32 @@
47
52
  */
48
53
  Quaternion result = R * P * Q;//順番が大事
49
54
 
50
- *x = result.v.x;
55
+ pos->x = result.v.x;
51
- *y = result.v.y;
56
+ pos->y = result.v.y;
52
- *z = result.v.z;
57
+ pos->z = result.v.z;
53
-
54
- }
55
-
56
-
57
-
58
- /* 一次変換 (x,y)の点を(mx,my)を中心にang角回転する */
59
- void rotate(float* x, float* y, const float ang, const float mx, const float my)
60
- {
61
58
 
62
- const float ox = *x - mx, oy = *y - my;
63
- *x = (ox * cos(ang)) + (oy * sin(ang));
64
- *y = (-ox * sin(ang)) + (oy * cos(ang));
65
-
66
- *x += mx;
67
- *y += my;
68
-
69
-
70
59
  }
71
60
 
72
-
73
-
74
61
  void Game::Update()
75
62
  {
76
63
  /*カメラ回転*/
77
64
  if (Input::keyboard(KEY_INPUT_LEFT) > 0)
78
65
  {
79
- rotate(&cameraX, &cameraZ, +ROTATE_SPEED, targetX, targetZ);
66
+ // rotate(&cameraX, &cameraZ, +ROTATE_SPEED, targetX, targetZ,);
80
67
  }
81
68
  else if (Input::keyboard(KEY_INPUT_RIGHT) > 0)
82
69
  {
83
- rotate(&cameraX, &cameraZ, -ROTATE_SPEED, targetX, targetZ);
70
+ // rotate(&cameraX, &cameraZ, -ROTATE_SPEED, targetX, targetZ);
84
71
  }
85
72
  else if (Input::keyboard(KEY_INPUT_UP) > 0)
86
73
  {
87
- rotate_X(&cameraX, &cameraY,&cameraZ, -ROTATE_SPEED, targetX, targetY,targetZ);
74
+ // rotate_X(&cameraX, &cameraY,&cameraZ, -ROTATE_SPEED, targetX, targetY,targetZ);
88
75
  DrawFormatString(100,100,GetColor(255,255,255),"UP");
89
76
 
90
77
  }
91
78
  else if (Input::keyboard(KEY_INPUT_DOWN) > 0)
92
79
  {
93
- rotate_X(&cameraX, &cameraY, &cameraZ, +ROTATE_SPEED, targetX, targetY, targetZ);
80
+ // rotate_X(&cameraX, &cameraY, &cameraZ, +ROTATE_SPEED, targetX, targetY, targetZ);
94
81
  DrawFormatString(100, 100, GetColor(255, 255, 255), "Down");
95
82
 
96
83
  }
@@ -103,6 +90,53 @@
103
90
 
104
91
  }
105
92
 
93
+
94
+ /*色 変更*/
95
+ if(Input::keyboard(KEY_INPUT_SPACE) == 1)
96
+ {
97
+ ModeChange = !ModeChange;
98
+ }
99
+ /* false spcカラーを変更*/
100
+ if (Input::keyboard(KEY_INPUT_Z) > 0 && ModeChange == false)
101
+ {
102
+ color_spc.r += -1;
103
+ color_spc.g += -1;
104
+ color_spc.b += -1;
105
+
106
+ }
107
+ else if (Input::keyboard(KEY_INPUT_X) > 0 && ModeChange == false)
108
+ {
109
+ color_spc.r += 1;
110
+ color_spc.g += 1;
111
+ color_spc.b += 1;
112
+
113
+ /*true difカラー変更*/
114
+ }else if (Input::keyboard(KEY_INPUT_Z) > 0 && ModeChange == true)
115
+ {
116
+ color_dif.r += -1;
117
+ color_dif.g += -1;
118
+ color_dif.b += -1;
119
+
120
+ }
121
+ else if (Input::keyboard(KEY_INPUT_X) > 0 && ModeChange == true)
122
+ {
123
+ color_dif.r += 1;
124
+ color_dif.g += 1;
125
+ color_dif.b += 1;
126
+
127
+ }
128
+
129
+ if (Input::keyboard(KEY_INPUT_F1) == 1)
130
+ {
131
+ TextureMode = !TextureMode;
132
+ }
133
+
134
+
135
+
136
+
137
+
138
+
139
+
106
140
  }
107
141
  ```
108
142
 

10

文章とタイトルを編集しました。

2020/04/07 04:26

投稿

退会済みユーザー
title CHANGED
@@ -1,1 +1,1 @@
1
- クォータニオンによるカメラ回転を実装したが上手く動作しな原因が知りたい。回転前と後で動作が違
1
+ クォータニオンによるカメラ回転を実装したい。その時の空間を2Dのようにってしま原因とは
body CHANGED
@@ -1,16 +1,19 @@
1
- X軸回転の関数ですが Y軸Z軸の数値下がますが上手く周回しくれず、あと一歩のところで上手く回転できません
1
+ 参考サイトなどを見て計算式をプログラムに落し込んだ原因で以の症状のようなバグでるのかどうしてもわかりません
2
- これは何を間違えたのでしょうか?
3
2
 
4
- 質問ですが"回転ベクトル"とは何をすれば算出されるょうか?
3
+ 質問1、X軸回転の関数ですがクォータニオンの計算をしてカメラを回転させたいがクォータニオン同士の掛け算やベクトルの外積、内積の計算が正いのか?
5
4
 
5
+ 質問2、"回転軸ベクトル"とは何をすれば算出されるのでしょうか?
6
+
7
+ 質問3.以下の症状が修正できず、何が悪いのかわからない。
6
8
  症状は 実行時に上下に動かすと見事にクォータニオンしてくれますが左右に動いたあとrotate();関数が実行されてその後
7
- 上下に動かすとその**空間座標?を中心にくるくる回ってしまい**周回軌道のようなモン〇ンのカメラのような動作をしてくれません
9
+ 上下に動かすとその**空間座標?を中心にくるくる回ってしまいます**
8
10
 
11
+ やりたいこと **周回軌道のようなモン〇ンのカメラのようなカメラ動作をしてほしい。**
9
12
 
10
13
 
11
14
  ![イメージ説明](7036df702c017099eb73b3deb642844a.png)
12
- ![イメージ説明](0ea179463c2bbfeebdcaa870c57fcabe.png)
13
15
 
16
+
14
17
  参考サイト1 : http://marupeke296.com/DXG_No10_Quaternion.html
15
18
  参考サイト2 : http://marupeke296.com/COL_Basic_No1_InnerAndOuterProduct.html
16
19
  参考サイト3 :https://home.hiroshima-u.ac.jp/kyoshida/MathExercise/2015(1stSemester)/exercise1(no03).pdf
@@ -21,30 +24,33 @@
21
24
  /*X軸回転*/
22
25
  void Game::rotate_X(float *x,float *y,float *z,const float ang, const float mx,const float my,const float mz)
23
26
  {
27
+
28
+ //Quaternion Prev(0, Vector(*x - mx, *y - my, *z - mz));
29
+
30
+ Quaternion P(0,Vector(*x, *y, *z));//回転させる点
24
31
 
25
- // Quaternion Prev(0, Position(*x - mx, *y - my, *z - mz));//回転させる点
26
- Quaternion P(0,Position(*x, *y, *z));//回転させる点
27
- //Position v(-5, 0, 0);//回転させる軸
28
32
  MATRIX t = MGetRotX(ang);//回転させる軸
29
33
 
30
- VECTOR v2;
34
+ VECTOR v;
35
+ v.x = -1;
36
+ v.y = 0;
37
+ v.z = 0;
31
38
 
32
- v2.x = *x;
33
- v2.y = *y;
34
- v2.z = *z;
35
39
 
36
- VECTOR v = VTransform(v2,t);
37
- //Position v(ang,0,0);//回転させる軸
40
+ Quaternion Q(cos(ang / 2), Vector(v.x * sin(ang / 2), v.y * sin(ang / 2), v.z * sin(ang / 2)));
41
+ Quaternion R(cos(ang / 2), Vector(-v.x * sin(ang / 2) , -v.y * sin(ang / 2), -v.z * sin(ang / 2)));
38
42
 
43
+ /*
44
+ ofs << "result.x:" << result.v.x << std::endl;
45
+ ofs << "result.y:" << result.v.y << std::endl;
39
- Quaternion Q(cos(ang / 2), Position(v.x * sin(ang / 2), v.y * sin(ang / 2), v.z * sin(ang / 2)));
46
+ ofs<< "result.z:" << result.v.z <<"\n\n\n"<< std::endl;
47
+ */
40
- Quaternion R(cos(ang / 2), Position(-v.x * sin(ang / 2) , -v.y * sin(ang / 2), -v.z * sin(ang / 2)));
48
+ Quaternion result = R * P * Q;//順番が大事
41
49
 
42
- Quaternion r = Quaternion::mul(R , Q);
43
- Quaternion result = Quaternion::mul(r , P);
44
-
45
50
  *x = result.v.x;
46
51
  *y = result.v.y;
47
- *z = result.v.z;
52
+ *z = result.v.z;
53
+
48
54
  }
49
55
 
50
56
 
@@ -102,61 +108,103 @@
102
108
 
103
109
  ヘッダー部
104
110
  ```ここに言語を入力
105
- #include "Position.hpp"
111
+ #ifndef ___Vector_H
112
+ #define ___Vector_H
106
113
 
107
- /*クォータニオン*/
108
-
109
- Quaternion::Quaternion(float aa,Position vv)
114
+ //template<typename type>
115
+ class Vector
110
116
  {
111
- a = aa;
117
+ private:
112
118
 
113
- v.x = vv.x;
114
- v.y = vv.y;
115
- v.z = vv.z;
116
- }
117
119
 
120
+
121
+
122
+ public:
123
+
124
+
125
+ float x;
126
+ float y;
127
+ float z;
128
+
129
+ Vector(float xx, float yy, float zz);
130
+ Vector();
131
+
132
+
133
+
134
+
135
+
118
- Quaternion Quaternion::mul(Quaternion a, Quaternion b)
136
+ static Vector cross(Vector a, Vector b);//外積
137
+ static float dot(Vector a, Vector b);//内積
138
+
139
+
140
+ static Vector mul_scalar(float a, Vector v);//スカラーとベクトルの掛け算
141
+
142
+
143
+
144
+
145
+
146
+ Vector operator = (Vector v);
147
+ Vector operator + (Vector v);
148
+
149
+ };
150
+
151
+ //template<typename type>
152
+ class Quaternion
119
153
  {
120
- return Quaternion(a.a * b.a - Position::dot(a.v,b.v),
154
+ public:
121
- Position::Add(Position::mul(a.a ,b.v) , Position::mul(b.a , a.v) , Position::cross(a.v,b.v)));
122
- }
123
155
 
156
+ /*実部*/
157
+ float a;
124
158
 
159
+ /*虚部*/
160
+ // Vector<type> v;
161
+ Vector v;
125
162
 
163
+ Quaternion(float aa, Vector vv);
164
+ Quaternion();
126
165
 
166
+ Quaternion operator * (Quaternion t);
127
167
 
168
+
169
+ };
170
+
171
+
172
+
173
+
174
+ #endif
175
+
176
+ ```
177
+
178
+ ソースファイル
179
+ ```ここに言語を入力
180
+ #include "Vector.hpp"
181
+
182
+
128
- /*ベクトル x スカラー*/
183
+ /*ベクトル x スカラーの掛け算*/
129
- Position Position::mul(float a, Position v)
184
+ Vector Vector::mul_scalar(float a, Vector v)
130
185
  {
131
- return Position(a * v.x,a * v.y,a * v.z);
186
+ return Vector(a * v.x,a * v.y,a * v.z);
132
187
  }
133
188
 
134
- /*ベクトルの足し算*/
135
- Position Position::Add(Position a,Position b,Position c)
136
- {
137
- return Position(a.x + b.x + c.x, a.y + b.y + c.y,a.z + b.z + c.z);
138
189
 
139
- }
140
-
141
190
  /*外積 ベクトル x ベクトル*/
142
- Position Position::cross(Position a,Position b)
191
+ Vector Vector::cross(Vector a,Vector b)
143
192
  {
144
- return Position( (a.y * b.z) - (a.z * b.y),
193
+ return Vector( (a.y * b.z) - (a.z * b.y),
145
194
  (a.z * b.x) - (a.x * b.z),
146
195
  (a.x * b.y) - (a.y * b.x));
147
196
 
148
197
  }
149
198
 
150
199
  /*内積*/
151
- float Position::dot(Position a, Position b)
200
+ float Vector::dot(Vector a, Vector b)
152
201
  {
153
202
  return (a.x * b.x) + (a.y * b.y) + (a.z * a.z);
154
203
  }
155
204
 
156
- /*座標系*/
157
205
 
158
- //template<typename type>
206
+ /*コンストラクタ*/
159
- Position::Position(float xx,float yy,float zz)
207
+ Vector::Vector(float xx,float yy,float zz)
160
208
  {
161
209
  x = xx;
162
210
  y = yy;
@@ -165,8 +213,8 @@
165
213
 
166
214
 
167
215
 
168
- //template<typename type>
216
+ /*コンストラクタ*/
169
- Position::Position()
217
+ Vector::Vector()
170
218
  {
171
219
  x = 0.0f;
172
220
  y = 0.0f;
@@ -174,65 +222,62 @@
174
222
  }
175
223
 
176
224
 
225
+ /*オペレーター = */
226
+ Vector Vector::operator = (Vector v)
177
- ```
227
+ {
228
+ this->x = v.x;
229
+ this->y = v.y;
230
+ this->z = v.z;
178
231
 
179
- ソースファイル
180
- ```ここに言語を入力
232
+ return *this;
181
- #ifndef ___POSITION_H
233
+ }
182
- #define ___POSITION_H
183
234
 
235
+ /*オペレーター + */
184
- //template<typename type>
236
+ Vector Vector::operator + (Vector v)
185
- class Position
186
237
  {
187
- private:
238
+ Vector t;
239
+ t.x = this->x + v.x;
240
+ t.y = this->y + v.y;
241
+ t.z = this->z + v.z;
188
242
 
189
243
 
244
+ return t;
245
+ }
190
246
 
191
247
 
192
- public:
193
- float x;
194
- float y;
195
- float z;
196
248
 
197
- Position(float xx, float yy, float zz);
198
- Position();
199
249
 
250
+ /*コンストラクタ 実部、虚部(Vector) */
251
+ Quaternion::Quaternion(float aa, Vector vv)
252
+ {
253
+ a = aa;//実部
200
254
 
255
+ /*虚部*/
256
+ v = vv;
257
+ }
201
258
 
202
259
 
203
- static Position cross(Position a, Position b);//外積
204
- static float dot(Position a, Position b);//内積
205
-
206
- static Position mul(float a, Position v);
207
- static Position Add(Position a, Position b, Position c);
208
-
209
-
210
-
211
-
212
-
213
-
214
- };
215
-
216
- //template<typename type>
260
+ /*コンストラクタ 引数なし*/
217
- class Quaternion
261
+ Quaternion::Quaternion()
218
262
  {
219
- public:
220
263
 
221
- /*実部*/
264
+ a = 0.0f;//実部
222
- float a;
223
265
 
224
266
  /*虚部*/
225
- // Position<type> v;
226
- Position v;
267
+ v.x = 0.0f;
268
+ v.y = 0.0f;
269
+ v.z = 0.0f;
270
+ }
227
271
 
228
- Quaternion(float aa, Position vv);
272
+ /*クォータニオン同士の掛け算
229
273
 
274
+ A = (a; U)
275
+ B = (b; V)
276
+ AB = (ab - U・V; aV + bU + U×V)
277
+ */
230
- static Quaternion mul(Quaternion a, Quaternion b);//掛け算
278
+ Quaternion Quaternion::operator * ( Quaternion t )
279
+ {
280
+ return Quaternion(this->a * t.a - Vector::dot(this->v,t.v),Vector(Vector::mul_scalar(this->a,t.v) + Vector::mul_scalar(t.a,this->v) + Vector::cross(this->v,t.v)));
281
+ }
231
282
 
232
-
233
-
234
- };
235
-
236
-
237
- #endif
238
283
  ```

9

文章を再度追加

2020/04/06 11:32

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -1,6 +1,8 @@
1
1
  X軸回転の関数ですが Y軸とZ軸の数値が上がり下がりしますが上手く周回してくれず、あと一歩のところで上手く回転できません
2
2
  これは何を間違えたのでしょうか?
3
3
 
4
+ 質問ですが"回転軸ベクトル"とは何をすれば算出されるのでしょうか?
5
+
4
6
  症状は 実行時に上下に動かすと見事にクォータニオンしてくれますが左右に動いたあとrotate();関数が実行されてその後
5
7
  上下に動かすとその**空間座標?を中心にくるくる回ってしまい**周回軌道のようなモン〇ンのカメラのような動作をしてくれません
6
8
 

8

タイトルと文章を編集しました。

2020/04/06 08:27

投稿

退会済みユーザー
title CHANGED
@@ -1,1 +1,1 @@
1
- クォータニオンによるカメラ回転を実装したが上手く動作しない原因が知りたい。
1
+ クォータニオンによるカメラ回転を実装したが上手く動作しない原因が知りたい。回転前と後で動作が違う
body CHANGED
@@ -1,9 +1,11 @@
1
1
  X軸回転の関数ですが Y軸とZ軸の数値が上がり下がりしますが上手く周回してくれず、あと一歩のところで上手く回転できません
2
- これは何を間違えたのでしょうか? 提示画像2枚目の左上カメラ座標
2
+ これは何を間違えたのでしょうか?
3
- ※Update();で上、下どってもやっても一定の場所まで近くなりその後動作がおかしいです。
4
3
 
4
+ 症状は 実行時に上下に動かすと見事にクォータニオンしてくれますが左右に動いたあとrotate();関数が実行されてその後
5
+ 上下に動かすとその**空間座標?を中心にくるくる回ってしまい**周回軌道のようなモン〇ンのカメラのような動作をしてくれません
5
6
 
6
7
 
8
+
7
9
  ![イメージ説明](7036df702c017099eb73b3deb642844a.png)
8
10
  ![イメージ説明](0ea179463c2bbfeebdcaa870c57fcabe.png)
9
11
 
@@ -43,6 +45,24 @@
43
45
  *z = result.v.z;
44
46
  }
45
47
 
48
+
49
+
50
+ /* 一次変換 (x,y)の点を(mx,my)を中心にang角回転する */
51
+ void rotate(float* x, float* y, const float ang, const float mx, const float my)
52
+ {
53
+
54
+ const float ox = *x - mx, oy = *y - my;
55
+ *x = (ox * cos(ang)) + (oy * sin(ang));
56
+ *y = (-ox * sin(ang)) + (oy * cos(ang));
57
+
58
+ *x += mx;
59
+ *y += my;
60
+
61
+
62
+ }
63
+
64
+
65
+
46
66
  void Game::Update()
47
67
  {
48
68
  /*カメラ回転*/

7

タイトルを編集しました。

2020/04/06 01:39

投稿

退会済みユーザー
title CHANGED
@@ -1,1 +1,1 @@
1
- ゲーム数学 クォータニオンによるカメラ回転を実装したが上手く動作しない原因が知りたい。
1
+ クォータニオンによるカメラ回転を実装したが上手く動作しない原因が知りたい。
body CHANGED
File without changes

6

画像と提示コードと文章を再度編集しました。

2020/04/05 10:17

投稿

退会済みユーザー
title CHANGED
@@ -1,1 +1,1 @@
1
- ゲーム数学 クォータニオンによるカメラ回転を実装したが上手く動作しない原因が知りたい。
1
+ ゲーム数学 クォータニオンによるカメラ回転を実装したが上手く動作しない原因が知りたい。
body CHANGED
@@ -1,23 +1,37 @@
1
- X軸回転の関数ですが Y軸とZ軸の数値が上がり下がりしますがどんでもない大きさになってまってあと一歩のところで上手く回転できません
1
+ X軸回転の関数ですが Y軸とZ軸の数値が上がり下がりしますが上手く周回してくれず、あと一歩のところで上手く回転できません
2
2
  これは何を間違えたのでしょうか? 提示画像2枚目の左上カメラ座標
3
+ ※Update();で上、下どってもやっても一定の場所まで近くなりその後動作がおかしいです。
3
4
 
4
5
 
5
6
 
6
- ![イメージ説明](8e016f366f8322640a0b03384251ba06.png)
7
+ ![イメージ説明](7036df702c017099eb73b3deb642844a.png)
7
- ![イメージ説明](ac50cc4c1c91a8c673f00546cfc73e19.png)
8
+ ![イメージ説明](0ea179463c2bbfeebdcaa870c57fcabe.png)
9
+
8
10
  参考サイト1 : http://marupeke296.com/DXG_No10_Quaternion.html
9
11
  参考サイト2 : http://marupeke296.com/COL_Basic_No1_InnerAndOuterProduct.html
10
12
  参考サイト3 :https://home.hiroshima-u.ac.jp/kyoshida/MathExercise/2015(1stSemester)/exercise1(no03).pdf
11
13
 
14
+
15
+ 以下rotete_x();関数部です。引数にカメラ座標と注視点座標とラジアンを入れて回転させる予定
12
16
  ```ここに言語を入力
13
17
  /*X軸回転*/
14
18
  void Game::rotate_X(float *x,float *y,float *z,const float ang, const float mx,const float my,const float mz)
15
19
  {
16
20
 
17
- //Quaternion P(0, Position(*x - mx, *y - my, *z - mz));//回転させる点
21
+ // Quaternion Prev(0, Position(*x - mx, *y - my, *z - mz));//回転させる点
18
22
  Quaternion P(0,Position(*x, *y, *z));//回転させる点
19
- Position v(ang,0,0);//回転させる軸
23
+ //Position v(-5, 0, 0);//回転させる軸
24
+ MATRIX t = MGetRotX(ang);//回転させる軸
20
25
 
26
+ VECTOR v2;
27
+
28
+ v2.x = *x;
29
+ v2.y = *y;
30
+ v2.z = *z;
31
+
32
+ VECTOR v = VTransform(v2,t);
33
+ //Position v(ang,0,0);//回転させる軸
34
+
21
35
  Quaternion Q(cos(ang / 2), Position(v.x * sin(ang / 2), v.y * sin(ang / 2), v.z * sin(ang / 2)));
22
36
  Quaternion R(cos(ang / 2), Position(-v.x * sin(ang / 2) , -v.y * sin(ang / 2), -v.z * sin(ang / 2)));
23
37
 
@@ -25,61 +39,46 @@
25
39
  Quaternion result = Quaternion::mul(r , P);
26
40
 
27
41
  *x = result.v.x;
28
- *y = result.v.y;
42
+ *y = result.v.y;
29
- *z = result.v.z;
43
+ *z = result.v.z;
30
44
  }
31
- ```
32
45
 
33
- ヘッダー部
34
- ```ここに言語を入力
35
- #ifndef ___POSITION_H
46
+ void Game::Update()
36
- #define ___POSITION_H
37
-
38
- //template<typename type>
39
- class Position
40
47
  {
41
- private:
48
+ /*カメラ回転*/
49
+ if (Input::keyboard(KEY_INPUT_LEFT) > 0)
50
+ {
51
+ rotate(&cameraX, &cameraZ, +ROTATE_SPEED, targetX, targetZ);
52
+ }
53
+ else if (Input::keyboard(KEY_INPUT_RIGHT) > 0)
54
+ {
55
+ rotate(&cameraX, &cameraZ, -ROTATE_SPEED, targetX, targetZ);
56
+ }
57
+ else if (Input::keyboard(KEY_INPUT_UP) > 0)
58
+ {
59
+ rotate_X(&cameraX, &cameraY,&cameraZ, -ROTATE_SPEED, targetX, targetY,targetZ);
60
+ DrawFormatString(100,100,GetColor(255,255,255),"UP");
42
61
 
43
- public:
62
+ }
44
- float x;
63
+ else if (Input::keyboard(KEY_INPUT_DOWN) > 0)
64
+ {
65
+ rotate_X(&cameraX, &cameraY, &cameraZ, +ROTATE_SPEED, targetX, targetY, targetZ);
45
- float y;
66
+ DrawFormatString(100, 100, GetColor(255, 255, 255), "Down");
46
- float z;
47
67
 
68
+ }
69
+ if (Input::keyboard(KEY_INPUT_W) > 0)
70
+ {
71
+
72
+ }
48
- Position(float xx, float yy, float zz);
73
+ else if (Input::keyboard(KEY_INPUT_S) > 0)
49
- Position();
74
+ {
50
75
 
51
- static Position cross(Position a, Position b);//外積
52
- static float dot(Position a, Position b);//内積
76
+ }
53
77
 
54
- static Position mul(float a, Position v);
55
- static Position Add(Position a, Position b, Position c);
56
-
57
- };
78
+ }
58
-
59
- //template<typename type>
60
- class Quaternion
61
- {
62
- public:
63
-
64
- /*実部*/
65
- float a;
66
-
67
- /*虚部*/
68
- // Position<type> v;
69
- Position v;
70
-
71
- Quaternion(float aa, Position vv);
72
-
73
- static Quaternion mul(Quaternion a, Quaternion b);//掛け算
74
-
75
-
76
-
77
- };
78
-
79
- #endif
80
79
  ```
81
80
 
82
- スファイル
81
+ ヘッダ
83
82
  ```ここに言語を入力
84
83
  #include "Position.hpp"
85
84
 
@@ -96,7 +95,8 @@
96
95
 
97
96
  Quaternion Quaternion::mul(Quaternion a, Quaternion b)
98
97
  {
98
+ return Quaternion(a.a * b.a - Position::dot(a.v,b.v),
99
- return Quaternion(a.a + b.a - Position::dot(a.v,b.v), Position::Add(Position::mul(a.a ,b.v) , Position::mul(b.a , a.v) , Position::cross(a.v,b.v)));
99
+ Position::Add(Position::mul(a.a ,b.v) , Position::mul(b.a , a.v) , Position::cross(a.v,b.v)));
100
100
  }
101
101
 
102
102
 
@@ -109,18 +109,20 @@
109
109
  return Position(a * v.x,a * v.y,a * v.z);
110
110
  }
111
111
 
112
+ /*ベクトルの足し算*/
112
113
  Position Position::Add(Position a,Position b,Position c)
113
114
  {
114
115
  return Position(a.x + b.x + c.x, a.y + b.y + c.y,a.z + b.z + c.z);
115
116
 
116
117
  }
117
118
 
118
- /*外積*/
119
+ /*外積 ベクトル x ベクトル*/
119
120
  Position Position::cross(Position a,Position b)
120
121
  {
121
- return Position(a.y * b.y - b.y * a.z,
122
+ return Position( (a.y * b.z) - (a.z * b.y),
122
- (-1) * (a.x * b.z - b.x * a.z),
123
+ (a.z * b.x) - (a.x * b.z),
123
- a.x * b.y - b.x * a.y);
124
+ (a.x * b.y) - (a.y * b.x));
125
+
124
126
  }
125
127
 
126
128
  /*内積*/
@@ -149,4 +151,66 @@
149
151
  z = 0.0f;
150
152
  }
151
153
 
154
+
155
+ ```
156
+
157
+ ソースファイル
158
+ ```ここに言語を入力
159
+ #ifndef ___POSITION_H
160
+ #define ___POSITION_H
161
+
162
+ //template<typename type>
163
+ class Position
164
+ {
165
+ private:
166
+
167
+
168
+
169
+
170
+ public:
171
+ float x;
172
+ float y;
173
+ float z;
174
+
175
+ Position(float xx, float yy, float zz);
176
+ Position();
177
+
178
+
179
+
180
+
181
+ static Position cross(Position a, Position b);//外積
182
+ static float dot(Position a, Position b);//内積
183
+
184
+ static Position mul(float a, Position v);
185
+ static Position Add(Position a, Position b, Position c);
186
+
187
+
188
+
189
+
190
+
191
+
192
+ };
193
+
194
+ //template<typename type>
195
+ class Quaternion
196
+ {
197
+ public:
198
+
199
+ /*実部*/
200
+ float a;
201
+
202
+ /*虚部*/
203
+ // Position<type> v;
204
+ Position v;
205
+
206
+ Quaternion(float aa, Position vv);
207
+
208
+ static Quaternion mul(Quaternion a, Quaternion b);//掛け算
209
+
210
+
211
+
212
+ };
213
+
214
+
215
+ #endif
152
216
  ```

5

タイトルと文章を編集しました。

2020/04/05 05:14

投稿

退会済みユーザー
title CHANGED
@@ -1,1 +1,1 @@
1
- ゲーム数学 クォータニオン * クォータニオンの計算方法が知りたい。
1
+ ゲーム数学 クォータニオンによるカメラ回転を実装した上手く動作しない原因が知りたい。
body CHANGED
@@ -1,34 +1,152 @@
1
- 質問1、X軸回転のrotate_x();関数部の最後のR * P *Q;部の計算ですがプログラムではどう計算ればのでしょうか?
1
+ X軸回転の関数ですが Y軸とZ軸の数値ががり下がりしまがどんでもな大きさになってしまってあと一歩ところ上手く回転できません
2
- 数式では参考サイト1より出ています。
3
- 質問2、まベクトルxスカラー計算方法も知りたいす。
2
+ これは何を間違えたのでしょうか? 提示画像2枚目の左上カメラ座標
4
3
 
5
4
 
6
- ※数学ライブラリ関数すらでこないので質問しました。
7
5
 
8
-
9
-
10
-
11
- ![イメージ説明](43d3313a961c7f604126434b11730cc5.png)
6
+ ![イメージ説明](8e016f366f8322640a0b03384251ba06.png)
7
+ ![イメージ説明](ac50cc4c1c91a8c673f00546cfc73e19.png)
12
8
  参考サイト1 : http://marupeke296.com/DXG_No10_Quaternion.html
13
9
  参考サイト2 : http://marupeke296.com/COL_Basic_No1_InnerAndOuterProduct.html
14
10
  参考サイト3 :https://home.hiroshima-u.ac.jp/kyoshida/MathExercise/2015(1stSemester)/exercise1(no03).pdf
15
11
 
16
12
  ```ここに言語を入力
17
- #include "DxLib.h"
18
-
19
13
  /*X軸回転*/
20
- //カメラ座標、ラジアン、中心座標(画像の正方形ポリゴン)
21
- void rotate_X(float *x,float *y,float *z,const float ang, const float mx,const float my,const float mz)
14
+ void Game::rotate_X(float *x,float *y,float *z,const float ang, const float mx,const float my,const float mz)
22
15
  {
16
+
17
+ //Quaternion P(0, Position(*x - mx, *y - my, *z - mz));//回転させる点
18
+ Quaternion P(0,Position(*x, *y, *z));//回転させる点
19
+ Position v(ang,0,0);//回転させる軸
23
20
 
24
- Quaternion<float> P(0,*x - mx,*y - my,*z - mz);//回転させる点
21
+ Quaternion Q(cos(ang / 2), Position(v.x * sin(ang / 2), v.y * sin(ang / 2), v.z * sin(ang / 2)));
25
- Position<float> v(1,0,0);//回転させる軸
22
+ Quaternion R(cos(ang / 2), Position(-v.x * sin(ang / 2) , -v.y * sin(ang / 2), -v.z * sin(ang / 2)));
26
23
 
24
+ Quaternion r = Quaternion::mul(R , Q);
27
- Quaternion<float> Q(cos(ang / 2), v.x * sin(ang / 2), v.y * sin(ang / 2), v.z * sin(ang / 2));
25
+ Quaternion result = Quaternion::mul(r , P);
28
- Quaternion<float> R(cos(ang / 2),-v.x * sin(ang / 2) , -v.y * sin(ang / 2), -v.z * sin(ang / 2));
29
26
 
30
- Quaternion<float> result = R * Q * P;
27
+ *x = result.v.x;
28
+ *y = result.v.y;
29
+ *z = result.v.z;
30
+ }
31
+ ```
31
32
 
33
+ ヘッダー部
34
+ ```ここに言語を入力
35
+ #ifndef ___POSITION_H
36
+ #define ___POSITION_H
37
+
38
+ //template<typename type>
39
+ class Position
40
+ {
41
+ private:
42
+
43
+ public:
44
+ float x;
45
+ float y;
46
+ float z;
47
+
48
+ Position(float xx, float yy, float zz);
49
+ Position();
50
+
51
+ static Position cross(Position a, Position b);//外積
52
+ static float dot(Position a, Position b);//内積
53
+
54
+ static Position mul(float a, Position v);
55
+ static Position Add(Position a, Position b, Position c);
56
+
57
+ };
58
+
59
+ //template<typename type>
60
+ class Quaternion
61
+ {
62
+ public:
63
+
64
+ /*実部*/
65
+ float a;
66
+
67
+ /*虚部*/
68
+ // Position<type> v;
69
+ Position v;
70
+
71
+ Quaternion(float aa, Position vv);
72
+
73
+ static Quaternion mul(Quaternion a, Quaternion b);//掛け算
74
+
75
+
76
+
77
+ };
78
+
79
+ #endif
80
+ ```
81
+
82
+ ソースファイル
83
+ ```ここに言語を入力
84
+ #include "Position.hpp"
85
+
86
+ /*クォータニオン*/
87
+
88
+ Quaternion::Quaternion(float aa,Position vv)
89
+ {
90
+ a = aa;
91
+
92
+ v.x = vv.x;
93
+ v.y = vv.y;
94
+ v.z = vv.z;
32
95
  }
33
96
 
97
+ Quaternion Quaternion::mul(Quaternion a, Quaternion b)
98
+ {
99
+ return Quaternion(a.a + b.a - Position::dot(a.v,b.v), Position::Add(Position::mul(a.a ,b.v) , Position::mul(b.a , a.v) , Position::cross(a.v,b.v)));
100
+ }
101
+
102
+
103
+
104
+
105
+
106
+ /*ベクトル x スカラー*/
107
+ Position Position::mul(float a, Position v)
108
+ {
109
+ return Position(a * v.x,a * v.y,a * v.z);
110
+ }
111
+
112
+ Position Position::Add(Position a,Position b,Position c)
113
+ {
114
+ return Position(a.x + b.x + c.x, a.y + b.y + c.y,a.z + b.z + c.z);
115
+
116
+ }
117
+
118
+ /*外積*/
119
+ Position Position::cross(Position a,Position b)
120
+ {
121
+ return Position(a.y * b.y - b.y * a.z,
122
+ (-1) * (a.x * b.z - b.x * a.z),
123
+ a.x * b.y - b.x * a.y);
124
+ }
125
+
126
+ /*内積*/
127
+ float Position::dot(Position a, Position b)
128
+ {
129
+ return (a.x * b.x) + (a.y * b.y) + (a.z * a.z);
130
+ }
131
+
132
+ /*座標系*/
133
+
134
+ //template<typename type>
135
+ Position::Position(float xx,float yy,float zz)
136
+ {
137
+ x = xx;
138
+ y = yy;
139
+ z = zz;
140
+ }
141
+
142
+
143
+
144
+ //template<typename type>
145
+ Position::Position()
146
+ {
147
+ x = 0.0f;
148
+ y = 0.0f;
149
+ z = 0.0f;
150
+ }
151
+
34
152
  ```

4

文章を編集しました。

2020/04/04 12:46

投稿

退会済みユーザー
title CHANGED
@@ -1,1 +1,1 @@
1
- ゲーム数学と数学の違いが知りたい。クォータニオン 内積と外積
1
+ ゲーム数学 クォータニオン * クォータニオンの計算方法が知りたい。
body CHANGED
@@ -1,17 +1,12 @@
1
- 参考サイト2の3番の数式を使ってある点を中心にカメラをX軸回転させる(上下)のですがクォータニオンを使えばいいと思ったすが
1
+ 質問1、X軸回転のrotate_x();関数部最後のR * P *Q;部の計算ですがプログラム上ではどう計算すればいいのでしょうか?
2
- P = (0; xp, yp, zp)=(0; Vp)動か点なのでカメラ座標を入れる?
2
+ 数式で参考サイト1より出ていま
3
- v = (xv, yv, zv)のコドは1,0,0としてX軸の方向を表せばい?
3
+ 質問2、またベクトルxスカラーの計算法も知りたです。
4
4
 
5
- Q = (cos(θ/2); xv・sin(θ/2), yv・sin(θ/2), zv・sin(θ/2))
6
- R = (cos(θ/2); -xv・sin(θ/2), -yv・sin(θ/2), -zv・sin(θ/2))
7
- この二つの式の ・ はドット積ですが単純な掛け算でしょうか?
8
5
 
9
- 最後の式は掛け算とありますが参考サト1のクォータニオンの基礎の掛け算でベクトルの内積、外積の計算を調べましたがどうればいいのしょうか?Q1 * Q2のサンプルのようにやると結果が一つにってしまうので最後のx,y,zの座標が作れな気がするのですが?
6
+ ※数学ラブラリ関数ないので質問しました。
10
7
 
11
- R*P*Q = (0; x, y, z)
12
8
 
13
9
 
14
- そもそも**ある点を中心にカメラをX軸回転させる(上下)**処理はこれで実現できるのでしょうか?
15
10
 
16
11
  ![イメージ説明](43d3313a961c7f604126434b11730cc5.png)
17
12
  参考サイト1 : http://marupeke296.com/DXG_No10_Quaternion.html

3

文章とタイトルを編集しました。

2020/04/04 11:37

投稿

退会済みユーザー
title CHANGED
@@ -1,1 +1,1 @@
1
- 中心点を中心にカメラ回転するクォータニオンを使えばいいのか?
1
+ ゲーム数学と数学の違いが知りたい。クォータニオン 内積と外積
body CHANGED
@@ -1,520 +1,39 @@
1
- 参考サイトの番の数式を使ってある点を中心にカメラをX軸回転させる(上下)なのですがクォータニオンを使えばいいと思ったののですが
1
+ 参考サイト23番の数式を使ってある点を中心にカメラをX軸回転させる(上下)なのですがクォータニオンを使えばいいと思ったののですが
2
- P = (0; xp, yp, zp)=(0; Vp)はしょうか
2
+ P = (0; xp, yp, zp)=(0; Vp)は動かす点なのでカメラ座標を入れる
3
- 二番目のv = (xv, yv, zv)のコードは1,0,0としてX軸の方向を表せばいいと思います。
3
+ v = (xv, yv, zv)のコードは1,0,0としてX軸の方向を表せばいい
4
4
 
5
+ Q = (cos(θ/2); xv・sin(θ/2), yv・sin(θ/2), zv・sin(θ/2))
6
+ R = (cos(θ/2); -xv・sin(θ/2), -yv・sin(θ/2), -zv・sin(θ/2))
5
- そもそも**ある点を中心にカメラをX軸回転させる(上下)**処理はれで実現できるのでしょうか?
7
+ この二つの式の ・ はドット積すが単純な掛け算でしょうか?
6
8
 
7
- ![イメージ説明](43d3313a961c7f604126434b11730cc5.png)
8
- 参考サイト: http://marupeke296.com/DXG_No10_Quaternion.html
9
+ 最後の式は掛け算とありますが参考サイト1のクォータニオンの基礎の掛け算でベクトルの内積、外積の計算を調べましたがどうすればいいのでしょうか?Q1 * Q2のサンプルのようにやると結果が一つになってしまうので最後のx,y,zの座標が作れない気がするのですが?
9
- ```ここに言語を入力
10
- #include "DxLib.h"
11
10
 
12
- #include "Game.hpp"
11
+ R*P*Q = (0; x, y, z)
13
- #include "Input.hpp"
14
- #include "Frame.hpp"
15
12
 
16
13
 
14
+ そもそも**ある点を中心にカメラをX軸回転させる(上下)**処理はこれで実現できるのでしょうか?
17
15
 
18
- Game::Game()
16
+ ![イメージ説明](43d3313a961c7f604126434b11730cc5.png)
19
- {
17
+ 参考サイト1 : http://marupeke296.com/DXG_No10_Quaternion.html
18
+ 参考サイト2 : http://marupeke296.com/COL_Basic_No1_InnerAndOuterProduct.html
19
+ 参考サイト3 :https://home.hiroshima-u.ac.jp/kyoshida/MathExercise/2015(1stSemester)/exercise1(no03).pdf
20
20
 
21
+ ```ここに言語を入力
21
- SetUseLighting(true);
22
+ #include "DxLib.h"
22
23
 
23
- SetUseZBuffer3D(true);
24
- SetWriteZBuffer3D(true);
25
-
26
- /*手前*/
27
- Vertex[0].pos = VGet(-RANGE, RANGE, 10);
28
- Vertex[0].norm = VGet(0.0f, 0.0f, -1.0f);
29
- Vertex[0].dif = color_dif;
30
- Vertex[0].spc = color_spc;
31
- Vertex[0].u = 0.0f;
32
- Vertex[0].v = 0.0f;
33
- Vertex[0].su = 0.0f;
34
- Vertex[0].sv = 0.0f;
35
-
36
- Vertex[1].pos = VGet(RANGE, RANGE, 10);
37
- Vertex[1].norm = VGet(0.0f, 0.0f, -1.0f);
38
- Vertex[1].dif = color_dif;
39
- Vertex[1].spc = color_spc;
40
- Vertex[1].u = 1.0f;
41
- Vertex[1].v = 0.0f;
42
- Vertex[1].su = 0.0f;
43
- Vertex[1].sv = 0.0f;
44
-
45
- Vertex[2].pos = VGet(-RANGE, -RANGE, 10);
46
- Vertex[2].norm = VGet(0.0f, 0.0f, -1.0f);
47
- Vertex[2].dif = color_dif;
48
- Vertex[2].spc = color_spc;
49
- Vertex[2].u = 0.0f;
50
- Vertex[2].v = 1.0f;
51
- Vertex[2].su = 0.0f;
52
- Vertex[2].sv = 0.0f;
53
-
54
- Vertex[3].pos = VGet(RANGE, -RANGE, 10);
55
- Vertex[3].norm = VGet(0.0f, 0.0f, -1.0f);
56
- Vertex[3].dif = color_dif;
57
- Vertex[3].spc = color_spc;
58
- Vertex[3].u = 1.0f;
59
- Vertex[3].v = 1.0f;
60
- Vertex[3].su = 0.0f;
61
- Vertex[3].sv = 0.0f;
62
-
63
- /*奥*/
64
- Vertex[4].pos = VGet(-RANGE, RANGE, 10 + RANGE);
65
- Vertex[4].norm = VGet(0.0f, 0.0f, -1.0f);
66
- Vertex[4].dif = color_dif;
67
- Vertex[4].spc = color_spc;
68
- Vertex[4].u = 0.0f;
69
- Vertex[4].v = 0.0f;
70
- Vertex[4].su = 0.0f;
71
- Vertex[4].sv = 0.0f;
72
-
73
- Vertex[5].pos = VGet(RANGE, RANGE, 10 + RANGE);
74
- Vertex[5].norm = VGet(0.0f, 0.0f, -1.0f);
75
- Vertex[5].dif = color_dif;
76
- Vertex[5].spc = color_spc;
77
- Vertex[5].u = 1.0f;
78
- Vertex[5].v = 0.0f;
79
- Vertex[5].su = 0.0f;
80
- Vertex[5].sv = 0.0f;
81
-
82
- Vertex[6].pos = VGet(-RANGE, -RANGE, 10 + RANGE);
83
- Vertex[6].norm = VGet(0.0f, 0.0f, -1.0f);
84
- Vertex[6].dif = color_dif;
85
- Vertex[6].spc = color_spc;
86
- Vertex[6].u = 0.0f;
87
- Vertex[6].v = 1.0f;
88
- Vertex[6].su = 0.0f;
89
- Vertex[6].sv = 0.0f;
90
-
91
- Vertex[7].pos = VGet(RANGE, -RANGE, 10 + RANGE);
92
- Vertex[7].norm = VGet(0.0f, 0.0f, -1.0f);
93
- Vertex[7].dif = color_dif;
94
- Vertex[7].spc = color_spc;
95
- Vertex[7].u = 1.0f;
96
- Vertex[7].v = 1.0f;
97
- Vertex[7].su = 0.0f;
98
- Vertex[7].sv = 0.0f;
99
- #define GROUND_Z 200
100
- #define GROUND_X 200
101
-
102
- /*地面 ポリゴン*/
103
- Ground_Vertex[0].pos = VGet( -RANGE * GROUND_X, -RANGE * 2, RANGE * GROUND_Z);
104
- Ground_Vertex[0].norm = VGet(0.0f, 0.0f, -1.0f);
105
- Ground_Vertex[0].dif = color_dif;
106
- Ground_Vertex[0].spc = color_spc;
107
- Ground_Vertex[0].u = 0.0f;
108
- Ground_Vertex[0].v = 0.0f;
109
-
110
- Ground_Vertex[1].pos = VGet(RANGE * GROUND_X, -RANGE * 2, RANGE * GROUND_Z);
111
- Ground_Vertex[1].norm = VGet(0.0f, 0.0f, -1.0f);
112
- Ground_Vertex[1].dif = color_dif;
113
- Ground_Vertex[1].spc = color_spc;
114
- Ground_Vertex[1].u = 1.0f;
115
- Ground_Vertex[1].v = 0.0f;
116
-
117
- Ground_Vertex[2].pos = VGet(-RANGE * GROUND_X, -RANGE * 2, GROUND_Z * -RANGE);
118
- Ground_Vertex[2].norm = VGet(0.0f, 0.0f, -1.0f);
119
- Ground_Vertex[2].dif = color_dif;
120
- Ground_Vertex[2].spc = color_spc;
121
- Ground_Vertex[2].u = 0.0f;
122
- Ground_Vertex[2].v = 1.0f;
123
-
124
- Ground_Vertex[3].pos = VGet(RANGE * GROUND_X, -RANGE * 2, GROUND_Z * -RANGE);
125
- Ground_Vertex[3].norm = VGet(0.0f, 0.0f, -1.0f);
126
- Ground_Vertex[3].dif = color_dif;
127
- Ground_Vertex[3].spc = color_spc;
128
- Ground_Vertex[3].u = 1.0f;
129
- Ground_Vertex[3].v = 1.0f;
130
-
131
- /*地面インデックス*/
132
- Ground_Index[0] = 0;
133
- Ground_Index[1] = 1;
134
- Ground_Index[2] = 2;
135
-
136
- Ground_Index[3] = 1;
137
- Ground_Index[4] = 2;
138
- Ground_Index[5] = 3;
139
-
140
-
141
-
142
- /*手前*/
143
- Index[0][0] = 0;
144
- Index[0][1] = 1;
145
- Index[0][2] = 2;
146
-
147
- Index[0][3] = 1;
148
- Index[0][4] = 2;
149
- Index[0][5] = 3;
150
-
151
- /*奥*/
152
- Index[1][0] = 4;
153
- Index[1][1] = 5;
154
- Index[1][2] = 6;
155
-
156
- Index[1][3] = 6;
157
- Index[1][4] = 5;
158
- Index[1][5] = 7;
159
-
160
- /*左*/
161
- Index[2][0] = 0;
162
- Index[2][1] = 4;
163
- Index[2][2] = 2;
164
-
165
- Index[2][3] = 4;
166
- Index[2][4] = 2;
167
- Index[2][5] = 6;
168
-
169
-
170
- /*右*/
171
- Index[3][0] = 1;
172
- Index[3][1] = 5;
173
- Index[3][2] = 7;
174
-
175
- Index[3][3] = 1;
176
- Index[3][4] = 3;
177
- Index[3][5] = 7;
178
-
179
-
180
-
181
-
182
- /*上*/
183
- Index[4][0] = 0;
184
- Index[4][1] = 4;
185
- Index[4][2] = 5;
186
-
187
- Index[4][3] = 0;
188
- Index[4][4] = 1;
189
- Index[4][5] = 5;
190
-
191
-
192
- /*下*/
193
- Index[5][0] = 6;
194
- Index[5][1] = 7;
195
- Index[5][2] = 2;
196
-
197
- Index[5][3] = 3;
198
- Index[5][4] = 7;
199
- Index[5][5] = 2;
200
-
201
-
202
- }
203
-
204
-
205
- /* (x,y)の点を(mx,my)を中心にang角回転する */
206
- void rotate(float* x, float* y, const float ang, const float mx, const float my)
207
- {
208
-
209
- const float ox = *x - mx, oy = *y - my;
210
- *x = (ox * cos(ang)) + (oy * sin(ang));
211
- *y = (-ox * sin(ang)) + (oy * cos(ang));
212
-
213
- *x += mx;
214
- *y += my;
215
-
216
-
217
- }
218
-
219
24
  /*X軸回転*/
25
+ //カメラ座標、ラジアン、中心座標(画像の正方形ポリゴン)
220
- void rotate_X(float *y,float *z,const float ang,const float my,const float mz)
26
+ void rotate_X(float *x,float *y,float *z,const float ang, const float mx,const float my,const float mz)
221
27
  {
222
- const float oy = *y - my;
223
- const float oz = *z - mz;
224
28
 
29
+ Quaternion<float> P(0,*x - mx,*y - my,*z - mz);//回転させる点
225
- *y = (oy * cos(ang)) + (oz * sin(ang));
30
+ Position<float> v(1,0,0);//回転させる軸
226
- *z = (-oy * sin(ang)) + (oz * cos(ang));
227
31
 
228
- *y += my;
32
+ Quaternion<float> Q(cos(ang / 2), v.x * sin(ang / 2), v.y * sin(ang / 2), v.z * sin(ang / 2));
229
- *z += mz;
33
+ Quaternion<float> R(cos(ang / 2),-v.x * sin(ang / 2) , -v.y * sin(ang / 2), -v.z * sin(ang / 2));
230
34
 
35
+ Quaternion<float> result = R * Q * P;
231
36
 
232
37
  }
233
38
 
234
- void Game::Update()
235
- {
236
- /*カメラ回転*/
237
- if (Input::keyboard(KEY_INPUT_LEFT) > 0)
238
- {
239
- rotate(&cameraX, &cameraZ, +ROTATE_SPEED, targetX, targetZ);
240
- }
241
- else if (Input::keyboard(KEY_INPUT_RIGHT) > 0)
242
- {
243
- rotate(&cameraX, &cameraZ, -ROTATE_SPEED, targetX, targetZ);
244
- }
245
- else if (Input::keyboard(KEY_INPUT_UP) > 0)
246
- {
247
- rotate_X(&cameraY, &cameraZ, -ROTATE_SPEED, targetY, targetZ);
248
- }
249
- else if (Input::keyboard(KEY_INPUT_DOWN) > 0)
250
- {
251
- rotate_X(&cameraY, &cameraZ, +ROTATE_SPEED, targetY, targetZ);
252
- }
253
- if (Input::keyboard(KEY_INPUT_W) > 0)
254
- {
255
-
256
- }
257
- else if (Input::keyboard(KEY_INPUT_S) > 0)
258
- {
259
-
260
- }
261
-
262
-
263
- /*色 変更*/
264
- if(Input::keyboard(KEY_INPUT_SPACE) == 1)
265
- {
266
- ModeChange = !ModeChange;
267
- }
268
- /* false spcカラーを変更*/
269
- if (Input::keyboard(KEY_INPUT_Z) > 0 && ModeChange == false)
270
- {
271
- color_spc.r += -1;
272
- color_spc.g += -1;
273
- color_spc.b += -1;
274
-
275
- }
276
- else if (Input::keyboard(KEY_INPUT_X) > 0 && ModeChange == false)
277
- {
278
- color_spc.r += 1;
279
- color_spc.g += 1;
280
- color_spc.b += 1;
281
-
282
- /*true difカラー変更*/
283
- }else if (Input::keyboard(KEY_INPUT_Z) > 0 && ModeChange == true)
284
- {
285
- color_dif.r += -1;
286
- color_dif.g += -1;
287
- color_dif.b += -1;
288
-
289
- }
290
- else if (Input::keyboard(KEY_INPUT_X) > 0 && ModeChange == true)
291
- {
292
- color_dif.r += 1;
293
- color_dif.g += 1;
294
- color_dif.b += 1;
295
-
296
- }
297
-
298
- if (Input::keyboard(KEY_INPUT_F1) == 1)
299
- {
300
- TextureMode = !TextureMode;
301
- }
302
-
303
-
304
- const int num = 4;
305
-
306
-
307
-
308
-
309
-
310
- }
311
- VECTOR v;
312
-
313
-
314
-
315
- //45,48
316
-
317
- void Game::DrawUpdate()
318
- {
319
- SetCameraPositionAndTarget_UpVecY(VGet(cameraX, cameraY, cameraZ), VGet(targetX, targetY, targetZ));
320
-
321
-
322
-
323
- for(int i = 0; i< 8; i++)
324
- {
325
- Vertex[i].dif = color_dif;
326
- Vertex[i].spc = color_spc;
327
-
328
- }
329
-
330
-
331
-
332
- int handle = LoadGraph("assets/resource/texturePos.png",false);
333
-
334
- for(int i =0 ;i < 6; i++){
335
-
336
- switch( i )
337
- {
338
- case 0:
339
- {
340
- Vertex[ 0 ].u = 0.0f;
341
- Vertex[ 0 ].v = 0.0f;
342
-
343
- Vertex[ 1 ].u = 1.0f;
344
- Vertex[ 1 ].v = 0.0f;
345
-
346
- Vertex[ 2 ].u = 0.0f;
347
- Vertex[ 2 ].v = 1.0f;
348
-
349
- Vertex[ 3 ].u = 1.0f;
350
- Vertex[ 3 ].v = 1.0f;
351
-
352
- Vertex[ 4 ].u = 1.0f;
353
- Vertex[ 4 ].v = 1.0f;
354
-
355
- Vertex[ 5 ].u = 0.0f;
356
- Vertex[ 5 ].v = 0.0f;
357
-
358
- Vertex[ 6 ].u = 0.0f;
359
- Vertex[ 6 ].v = 0.0f;
360
-
361
- Vertex[ 7 ].u = 0.0f;
362
- Vertex[ 7 ].v = 0.0f;
363
- }
364
- break;
365
-
366
-
367
- case 1:
368
- {
369
- Vertex[0].u = 0.0f;
370
- Vertex[0].v = 0.0f;
371
-
372
- Vertex[1].u = 1.0f;
373
- Vertex[1].v = 0.0f;
374
-
375
- Vertex[2].u = 0.0f;
376
- Vertex[2].v = 1.0f;
377
-
378
- Vertex[3].u = 0.0f;
379
- Vertex[3].v = 0.0f;
380
-
381
- Vertex[4].u = 0.0f;
382
- Vertex[4].v = 0.0f;
383
-
384
- Vertex[5].u = 1.0f;
385
- Vertex[5].v = 0.0f;
386
-
387
- Vertex[6].u = 0.0f;
388
- Vertex[6].v = 1.0f;
389
-
390
- Vertex[7].u = 1.0f;
391
- Vertex[7].v = 1.0f;
392
-
393
- }
394
- break;
395
-
396
-
397
- case 2:
398
- {
399
-
400
- Vertex[0].u = 1.0f;
401
- Vertex[0].v = 0.0f;
402
-
403
- Vertex[1].u = 1.0f;
404
- Vertex[1].v = 0.0f;
405
-
406
- Vertex[2].u = 1.0f;
407
- Vertex[2].v = 1.0f;
408
-
409
- Vertex[3].u = 0.0f;
410
- Vertex[3].v = 0.0f;
411
-
412
-
413
-
414
- Vertex[4].u = 0.0f;
415
- Vertex[4].v = 0.0f;
416
-
417
- Vertex[5].u = 0.0f;
418
- Vertex[5].v = 1.0f;
419
-
420
- Vertex[6].u = 0.0f;
421
- Vertex[6].v = 1.0f;
422
-
423
- Vertex[7].u = 1.0f;
424
- Vertex[7].v = 1.0f;
425
-
426
- }
427
- break;
428
-
429
- /*右*/
430
- case 3:
431
- {
432
-
433
- Vertex[0].u = 1.0f;
434
- Vertex[0].v = 0.0f;
435
-
436
- Vertex[1].u = 0.0f;
437
- Vertex[1].v = 0.0f;
438
-
439
- Vertex[2].u = 1.0f;
440
- Vertex[2].v = 1.0f;
441
-
442
- Vertex[3].u = 0.0f;
443
- Vertex[3].v = 1.0f;
444
-
445
-
446
-
447
- Vertex[4].u = 0.0f;
448
- Vertex[4].v = 0.0f;
449
-
450
- Vertex[5].u = 1.0f;
451
- Vertex[5].v = 0.0f;
452
-
453
- Vertex[6].u = 0.0f;
454
- Vertex[6].v = 1.0f;
455
-
456
- Vertex[7].u = 1.0f;
457
- Vertex[7].v = 1.0f;
458
-
459
- }
460
- break;
461
-
462
-
463
- /*上*/
464
- case 4:
465
- {
466
-
467
- Vertex[0].u = 0.0f;
468
- Vertex[0].v = 0.0f;
469
-
470
- Vertex[1].u = 0.0f;
471
- Vertex[1].v = 1.0f;
472
-
473
- Vertex[4].u = 1.0f;
474
- Vertex[4].v = 0.0f;
475
-
476
- Vertex[5].u = 1.0f;
477
- Vertex[5].v = 1.0f;
478
-
479
- }
480
- break;
481
-
482
-
483
- /*下*/
484
- case 5:
485
- {
486
-
487
- Vertex[2].u = 0.0f;
488
- Vertex[2].v = 1.0f;
489
-
490
- Vertex[3].u = 1.0f;
491
- Vertex[3].v = 1.0f;
492
-
493
- Vertex[6].u = 0.0f;
494
- Vertex[6].v = 0.0f;
495
-
496
- Vertex[7].u = 1.0f;
497
- Vertex[7].v = 0.0f;
498
- }
499
- break;
500
- }
501
- if(TextureMode == true){
502
- DrawPolygonIndexed3D(Vertex, 8, Index[i], 2, handle, false);
503
- }else{
504
- DrawPolygonIndexed3D(Vertex, 8, Index[i], 2, DX_NONE_GRAPH, false);
505
- }
506
- }
507
-
508
- DrawPolygonIndexed3D(Ground_Vertex,4,Ground_Index,6,handle,false);
509
-
510
- // cameraY += -1;
511
-
512
-
513
- DrawFormatString(0, 0, GetColor(255, 255, 255), "カメラ座標 x: %.2f , y: %.2f , z:%.2f ", cameraX,cameraY,cameraZ);
514
- // DrawFormatString(0, 40, Get color;(255, 255, 255), " test x: %.2f z: %.2f", xx, zz);
515
-
516
-
517
-
518
-
519
- }
520
39
  ```

2

タイトルを文章を編集しました。

2020/04/04 06:29

投稿

退会済みユーザー
title CHANGED
@@ -1,1 +1,1 @@
1
- 中心点を中心にカメラ回転する回転式を使っても上手くできな下人が知りた
1
+ 中心点を中心にカメラ回転するクォータニオンを使えばいいのか?
body CHANGED
@@ -1,13 +1,11 @@
1
- カメラX軸回転させて正方形ポリゴンの下の貼ってあるポリゴンを見ようとしたのですが十字キの上押し続けるその場所にぐるぐる回てしまい上手く中心点を中心に回ってくれませんこれは何が原因なのでしょうか? void rotate_X();関数部で
1
+ 参考サイトの②番の数式を使ってある点を中心にカメラX軸回転させる(上下)なのですがクォタニオン使えばいいです
2
- 実行した時座標のままだと正常に回ります。参考サイトのX軸周りの回転一番上の式
2
+ P = (0; xp, yp, zp)=(0; Vp)ははなん値でしょうか?
3
+ 二番目のv = (xv, yv, zv)のコードは1,0,0としてX軸の方向を表せばいいと思います。
3
4
 
5
+ そもそも**ある点を中心にカメラをX軸回転させる(上下)**処理はこれで実現できるのでしょうか?
4
6
 
5
- 参考サイト:http://www.f.waseda.jp/moriya/PUBLIC_HTML/education/classes/infomath6/applet/fractal/coord/
6
-
7
-
8
- ![イメージ説明](15429c92478bb10d229a1250417eb5e2.png)
7
+ ![イメージ説明](43d3313a961c7f604126434b11730cc5.png)
9
- ![メージ説明](dc2fec7bf579290f3eccf5ac66deb182.png)
8
+ 参考サト: http://marupeke296.com/DXG_No10_Quaternion.html
10
-
11
9
  ```ここに言語を入力
12
10
  #include "DxLib.h"
13
11
 
@@ -98,9 +96,49 @@
98
96
  Vertex[7].v = 1.0f;
99
97
  Vertex[7].su = 0.0f;
100
98
  Vertex[7].sv = 0.0f;
99
+ #define GROUND_Z 200
100
+ #define GROUND_X 200
101
101
 
102
+ /*地面 ポリゴン*/
103
+ Ground_Vertex[0].pos = VGet( -RANGE * GROUND_X, -RANGE * 2, RANGE * GROUND_Z);
104
+ Ground_Vertex[0].norm = VGet(0.0f, 0.0f, -1.0f);
105
+ Ground_Vertex[0].dif = color_dif;
106
+ Ground_Vertex[0].spc = color_spc;
107
+ Ground_Vertex[0].u = 0.0f;
108
+ Ground_Vertex[0].v = 0.0f;
102
109
 
110
+ Ground_Vertex[1].pos = VGet(RANGE * GROUND_X, -RANGE * 2, RANGE * GROUND_Z);
111
+ Ground_Vertex[1].norm = VGet(0.0f, 0.0f, -1.0f);
112
+ Ground_Vertex[1].dif = color_dif;
113
+ Ground_Vertex[1].spc = color_spc;
114
+ Ground_Vertex[1].u = 1.0f;
115
+ Ground_Vertex[1].v = 0.0f;
103
116
 
117
+ Ground_Vertex[2].pos = VGet(-RANGE * GROUND_X, -RANGE * 2, GROUND_Z * -RANGE);
118
+ Ground_Vertex[2].norm = VGet(0.0f, 0.0f, -1.0f);
119
+ Ground_Vertex[2].dif = color_dif;
120
+ Ground_Vertex[2].spc = color_spc;
121
+ Ground_Vertex[2].u = 0.0f;
122
+ Ground_Vertex[2].v = 1.0f;
123
+
124
+ Ground_Vertex[3].pos = VGet(RANGE * GROUND_X, -RANGE * 2, GROUND_Z * -RANGE);
125
+ Ground_Vertex[3].norm = VGet(0.0f, 0.0f, -1.0f);
126
+ Ground_Vertex[3].dif = color_dif;
127
+ Ground_Vertex[3].spc = color_spc;
128
+ Ground_Vertex[3].u = 1.0f;
129
+ Ground_Vertex[3].v = 1.0f;
130
+
131
+ /*地面インデックス*/
132
+ Ground_Index[0] = 0;
133
+ Ground_Index[1] = 1;
134
+ Ground_Index[2] = 2;
135
+
136
+ Ground_Index[3] = 1;
137
+ Ground_Index[4] = 2;
138
+ Ground_Index[5] = 3;
139
+
140
+
141
+
104
142
  /*手前*/
105
143
  Index[0][0] = 0;
106
144
  Index[0][1] = 1;
@@ -188,7 +226,7 @@
188
226
  *z = (-oy * sin(ang)) + (oz * cos(ang));
189
227
 
190
228
  *y += my;
191
- *z += mz;
229
+ *z += mz;
192
230
 
193
231
 
194
232
  }
@@ -214,11 +252,11 @@
214
252
  }
215
253
  if (Input::keyboard(KEY_INPUT_W) > 0)
216
254
  {
217
- cameraZ += -4;
255
+
218
256
  }
219
257
  else if (Input::keyboard(KEY_INPUT_S) > 0)
220
258
  {
221
- y -= 2;
259
+
222
260
  }
223
261
 
224
262
 
@@ -257,9 +295,12 @@
257
295
 
258
296
  }
259
297
 
298
+ if (Input::keyboard(KEY_INPUT_F1) == 1)
299
+ {
300
+ TextureMode = !TextureMode;
301
+ }
260
302
 
261
303
 
262
-
263
304
  const int num = 4;
264
305
 
265
306
 
@@ -275,7 +316,7 @@
275
316
 
276
317
  void Game::DrawUpdate()
277
318
  {
278
- SetCameraPositionAndTarget_UpVecY(VGet(cameraX, cameraY, cameraZ), VGet(targetX, targetZ, targetZ));
319
+ SetCameraPositionAndTarget_UpVecY(VGet(cameraX, cameraY, cameraZ), VGet(targetX, targetY, targetZ));
279
320
 
280
321
 
281
322
 
@@ -319,18 +360,12 @@
319
360
 
320
361
  Vertex[ 7 ].u = 0.0f;
321
362
  Vertex[ 7 ].v = 0.0f;
322
-
323
-
324
-
325
-
326
- DrawPolygonIndexed3D(Vertex, 8, Index[i], 2, handle, false);
327
363
  }
328
364
  break;
329
365
 
330
366
 
331
367
  case 1:
332
- {
368
+ {
333
-
334
369
  Vertex[0].u = 0.0f;
335
370
  Vertex[0].v = 0.0f;
336
371
 
@@ -342,9 +377,7 @@
342
377
 
343
378
  Vertex[3].u = 0.0f;
344
379
  Vertex[3].v = 0.0f;
345
-
346
-
347
-
380
+
348
381
  Vertex[4].u = 0.0f;
349
382
  Vertex[4].v = 0.0f;
350
383
 
@@ -357,8 +390,6 @@
357
390
  Vertex[7].u = 1.0f;
358
391
  Vertex[7].v = 1.0f;
359
392
 
360
- DrawPolygonIndexed3D(Vertex, 8, Index[i], 2, handle, false);
361
-
362
393
  }
363
394
  break;
364
395
 
@@ -392,8 +423,6 @@
392
423
  Vertex[7].u = 1.0f;
393
424
  Vertex[7].v = 1.0f;
394
425
 
395
- DrawPolygonIndexed3D(Vertex, 8, Index[i], 2, handle, false);
396
-
397
426
  }
398
427
  break;
399
428
 
@@ -427,8 +456,6 @@
427
456
  Vertex[7].u = 1.0f;
428
457
  Vertex[7].v = 1.0f;
429
458
 
430
- DrawPolygonIndexed3D(Vertex, 8, Index[i], 2, handle, false);
431
-
432
459
  }
433
460
  break;
434
461
 
@@ -449,10 +476,6 @@
449
476
  Vertex[5].u = 1.0f;
450
477
  Vertex[5].v = 1.0f;
451
478
 
452
-
453
-
454
- DrawPolygonIndexed3D(Vertex, 8, Index[i], 2, handle, false);
455
-
456
479
  }
457
480
  break;
458
481
 
@@ -472,43 +495,26 @@
472
495
 
473
496
  Vertex[7].u = 1.0f;
474
497
  Vertex[7].v = 0.0f;
475
-
476
-
477
-
478
- DrawPolygonIndexed3D(Vertex, 8, Index[i], 2, handle, false);
479
-
480
498
  }
481
499
  break;
482
-
483
-
484
500
  }
485
-
501
+ if(TextureMode == true){
502
+ DrawPolygonIndexed3D(Vertex, 8, Index[i], 2, handle, false);
503
+ }else{
504
+ DrawPolygonIndexed3D(Vertex, 8, Index[i], 2, DX_NONE_GRAPH, false);
505
+ }
486
506
  }
487
507
 
488
-
508
+ DrawPolygonIndexed3D(Ground_Vertex,4,Ground_Index,6,handle,false);
489
509
 
510
+ // cameraY += -1;
490
511
 
491
512
 
492
-
493
- DrawFormatString(0, 0, GetColor(255, 255, 255), "x: %.2f , y: %.2f , z:%.2f ", cameraX,cameraY,cameraZ);
513
+ DrawFormatString(0, 0, GetColor(255, 255, 255), "カメラ座標 x: %.2f , y: %.2f , z:%.2f ", cameraX,cameraY,cameraZ);
494
514
  // DrawFormatString(0, 40, Get color;(255, 255, 255), " test x: %.2f z: %.2f", xx, zz);
495
515
 
496
- if(ModeChange == false){
516
+
497
- DrawFormatString(0, 32 * 5, GetColor(255, 255, 255), "Mode: spc ");
498
517
 
499
- DrawFormatString(0, 32 * 1, GetColor(255, 255, 255), "color_spc.r: %d", color_spc.r);
500
- DrawFormatString(0, 32 * 2, GetColor(255, 255, 255), "color_spc.g: %d", color_spc.g);
501
- DrawFormatString(0, 32 * 3, GetColor(255, 255, 255), "color_spc.b: %d", color_spc.b);
502
- }else
503
- {
504
- DrawFormatString(0, 32 * 5, GetColor(255, 255, 255), "Mode: dif ");
505
518
 
506
- DrawFormatString(0, 32 * 1, GetColor(255, 255, 255), "color_dif.r: %d", color_dif.r);
507
- DrawFormatString(0, 32 * 2, GetColor(255, 255, 255), "color_dif.g: %d", color_dif.g);
508
- DrawFormatString(0, 32 * 3, GetColor(255, 255, 255), "color_dif.b: %d", color_dif.b);
509
-
510
- }
511
-
512
-
513
519
  }
514
520
  ```

1

タイトルを編集しました。

2020/04/04 01:38

投稿

退会済みユーザー
title CHANGED
@@ -1,1 +1,1 @@
1
- カメラ回転で注視点が悪いか,回転が悪いのか?,そう見えるだけのか?知りたい
1
+ 中心点を中心にカメラ回転する回転式を使っても上手くできい下人が知りたい
body CHANGED
File without changes