Rev 21 | Rev 25 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 21 | Rev 24 | ||
---|---|---|---|
Line 40... | Line 40... | ||
40 | int column; |
40 | int column; |
41 | int index_line; |
41 | int index_line; |
42 | int index_column; |
42 | int index_column; |
43 | int part_index; |
43 | int part_index; |
44 | int part_color; |
44 | int part_color; |
- | 45 | int viewer_index; |
|
45 | 46 | ||
46 | // filter out the commonly used message values |
47 | // filter out the commonly used message values |
47 | wParam_hiword = HIWORD (wParam); |
48 | wParam_hiword = HIWORD (wParam); |
48 | wParam_loword = LOWORD (wParam); |
49 | wParam_loword = LOWORD (wParam); |
49 | 50 | ||
Line 211... | Line 212... | ||
211 | } |
212 | } |
212 | 213 | ||
213 | // chessboard menu, top view |
214 | // chessboard menu, top view |
214 | else if (wParam_loword == MENUID_CHESSBOARD_TOPVIEW) |
215 | else if (wParam_loword == MENUID_CHESSBOARD_TOPVIEW) |
215 | { |
216 | { |
- | 217 | // cycle through both players and change their view angles EXCEPT the opponent if he's human |
|
- | 218 | for (viewer_index = 0; viewer_index < 2; viewer_index++) |
|
- | 219 | if ((the_board.players[viewer_index].type == PLAYER_COMPUTER) |
|
- | 220 | || (the_board.players[viewer_index].type == PLAYER_INTERNET) |
|
- | 221 | || (viewer_index == current_viewer)) |
|
- | 222 | { |
|
216 | the_board.players[ |
223 | the_board.players[viewer_index].view_pitch = 89.0f; |
217 | the_board.players[ |
224 | the_board.players[viewer_index].view_yaw = (current_viewer == COLOR_BLACK ? 90.0f : -90.0f); |
218 | the_board.players[ |
225 | the_board.players[viewer_index].view_distance = 58.0f; |
- | 226 | } |
|
219 | } |
227 | } |
220 | 228 | ||
221 | // chessboard menu, default view |
229 | // chessboard menu, default view |
222 | else if (wParam_loword == MENUID_CHESSBOARD_DEFAULTVIEW) |
230 | else if (wParam_loword == MENUID_CHESSBOARD_DEFAULTVIEW) |
223 | { |
231 | { |
- | 232 | // cycle through both players and change their view angles EXCEPT the opponent if he's human |
|
- | 233 | for (viewer_index = 0; viewer_index < 2; viewer_index++) |
|
- | 234 | if ((the_board.players[viewer_index].type == PLAYER_COMPUTER) |
|
- | 235 | || (the_board.players[viewer_index].type == PLAYER_INTERNET) |
|
- | 236 | || (viewer_index == current_viewer)) |
|
- | 237 | { |
|
224 | the_board.players[ |
238 | the_board.players[viewer_index].view_pitch = 55.0f; |
225 | the_board.players[ |
239 | the_board.players[viewer_index].view_yaw = (current_viewer == COLOR_BLACK ? 90.0f : -90.0f); |
226 | the_board.players[ |
240 | the_board.players[viewer_index].view_distance = 70.0f; |
- | 241 | } |
|
227 | } |
242 | } |
228 | 243 | ||
229 | // chessboard menu, reset view |
244 | // chessboard menu, reset view |
230 | else if (wParam_loword == MENUID_CHESSBOARD_RESETVIEW) |
245 | else if (wParam_loword == MENUID_CHESSBOARD_RESETVIEW) |
231 | { |
246 | { |
- | 247 | // cycle through both players and change their view angles EXCEPT the opponent if he's human |
|
- | 248 | for (viewer_index = 0; viewer_index < 2; viewer_index++) |
|
- | 249 | if ((the_board.players[viewer_index].type == PLAYER_COMPUTER) |
|
- | 250 | || (the_board.players[viewer_index].type == PLAYER_INTERNET) |
|
- | 251 | || (viewer_index == current_viewer)) |
|
- | 252 | { |
|
232 | the_board.players[ |
253 | the_board.players[viewer_index].view_pitch = the_board.players[current_viewer].custom_pitch; |
233 | the_board.players[ |
254 | the_board.players[viewer_index].view_yaw = the_board.players[current_viewer].custom_yaw; |
234 | the_board.players[ |
255 | the_board.players[viewer_index].view_distance = the_board.players[current_viewer].custom_distance; |
- | 256 | } |
|
235 | } |
257 | } |
236 | 258 | ||
237 | // chessboard menu, zoom in |
259 | // chessboard menu, zoom in |
238 | else if (wParam_loword == MENUID_CHESSBOARD_ZOOMIN) |
260 | else if (wParam_loword == MENUID_CHESSBOARD_ZOOMIN) |
239 | { |
261 | { |
Line 362... | Line 384... | ||
362 | { |
384 | { |
363 | prevgui_x = GET_X_LPARAM (lParam); // remember mouse coordinates |
385 | prevgui_x = GET_X_LPARAM (lParam); // remember mouse coordinates |
364 | prevgui_y = GET_Y_LPARAM (lParam); |
386 | prevgui_y = GET_Y_LPARAM (lParam); |
365 | 387 | ||
366 | // if we click something, stop moving the table immediately |
388 | // if we click something, stop moving the table immediately |
- | 389 | ||
- | 390 | // cycle through both players and change their view angles EXCEPT the opponent if he's human |
|
- | 391 | for (viewer_index = 0; viewer_index < 2; viewer_index++) |
|
- | 392 | if ((the_board.players[viewer_index].type == PLAYER_COMPUTER) |
|
- | 393 | || (the_board.players[viewer_index].type == PLAYER_INTERNET) |
|
- | 394 | || (viewer_index == current_viewer)) |
|
- | 395 | { |
|
367 | the_board.players[ |
396 | the_board.players[viewer_index].view_pitch = current_pitch; |
368 | the_board.players[ |
397 | the_board.players[viewer_index].view_yaw = current_yaw; |
- | 398 | } |
|
369 | 399 | ||
370 | rbutton_pushed = true; // remember button is clicked |
400 | rbutton_pushed = true; // remember button is clicked |
371 | } |
401 | } |
372 | 402 | ||
373 | // call the default window message processing function to keep things going |
403 | // call the default window message processing function to keep things going |
Line 665... | Line 695... | ||
665 | 695 | ||
666 | prevgui_x = GET_X_LPARAM (lParam); // remember mouse coordinates |
696 | prevgui_x = GET_X_LPARAM (lParam); // remember mouse coordinates |
667 | prevgui_y = GET_Y_LPARAM (lParam); |
697 | prevgui_y = GET_Y_LPARAM (lParam); |
668 | 698 | ||
669 | // if we click something, stop moving the table immediately |
699 | // if we click something, stop moving the table immediately |
- | 700 | ||
- | 701 | // cycle through both players and change their view angles EXCEPT the opponent if he's human |
|
- | 702 | for (viewer_index = 0; viewer_index < 2; viewer_index++) |
|
- | 703 | if ((the_board.players[viewer_index].type == PLAYER_COMPUTER) |
|
- | 704 | || (the_board.players[viewer_index].type == PLAYER_INTERNET) |
|
- | 705 | || (viewer_index == current_viewer)) |
|
- | 706 | { |
|
670 | the_board.players[ |
707 | the_board.players[viewer_index].view_pitch = current_pitch; |
671 | the_board.players[ |
708 | the_board.players[viewer_index].view_yaw = current_yaw; |
- | 709 | } |
|
672 | 710 | ||
673 | rbutton_pushed = true; // remember button is clicked |
711 | rbutton_pushed = true; // remember button is clicked |
674 | 712 | ||
675 | // call the default window message processing function to keep things going |
713 | // call the default window message processing function to keep things going |
676 | return (DefWindowProc (hWnd, message, wParam, lParam)); |
714 | return (DefWindowProc (hWnd, message, wParam, lParam)); |
Line 773... | Line 811... | ||
773 | opposite_player = Player_GetOpposite (); |
811 | opposite_player = Player_GetOpposite (); |
774 | 812 | ||
775 | // if right button was clicked, compute new pitch and yaw |
813 | // if right button was clicked, compute new pitch and yaw |
776 | if (rbutton_pushed) |
814 | if (rbutton_pushed) |
777 | { |
815 | { |
- | 816 | // cycle through both players and change their view angles EXCEPT the opponent if he's human |
|
- | 817 | for (viewer_index = 0; viewer_index < 2; viewer_index++) |
|
- | 818 | if ((the_board.players[viewer_index].type == PLAYER_COMPUTER) |
|
- | 819 | || (the_board.players[viewer_index].type == PLAYER_INTERNET) |
|
- | 820 | || (viewer_index == current_viewer)) |
|
- | 821 | { |
|
778 | the_board.players[ |
822 | the_board.players[viewer_index].view_pitch += (gui_y - prevgui_y) * 0.3f; |
779 | if (the_board.players[ |
823 | if (the_board.players[viewer_index].view_pitch < 10.0f) |
780 | the_board.players[ |
824 | the_board.players[viewer_index].view_pitch = 10.0f; // wrap angles around so that they |
781 | if (the_board.players[ |
825 | if (the_board.players[viewer_index].view_pitch > 89.0f) |
782 | the_board.players[ |
826 | the_board.players[viewer_index].view_pitch = 89.0f; // stay in the [10, 89] bounds |
783 | 827 | ||
784 | the_board.players[ |
828 | the_board.players[viewer_index].view_yaw += (gui_x - prevgui_x) * 0.3f; |
785 | the_board.players[ |
829 | the_board.players[viewer_index].view_yaw = WrapAngle (the_board.players[viewer_index].view_yaw); |
786 | 830 | ||
787 | // save these as the new custom angles |
831 | // save these as the new custom angles |
788 | the_board.players[ |
832 | the_board.players[viewer_index].custom_pitch = the_board.players[viewer_index].view_pitch; |
789 | the_board.players[ |
833 | the_board.players[viewer_index].custom_yaw = the_board.players[viewer_index].view_yaw; |
790 | 834 | ||
791 | // when moving the table around, jump to ideal angles immediately |
835 | // when moving the table around, jump to ideal angles immediately |
792 | current_pitch = the_board.players[ |
836 | current_pitch = the_board.players[viewer_index].view_pitch; |
793 | current_yaw = the_board.players[ |
837 | current_yaw = the_board.players[viewer_index].view_yaw; |
- | 838 | } |
|
794 | 839 | ||
795 | the_scene.update = true; // button was clicked, update the 3D scene |
840 | the_scene.update = true; // button was clicked, update the 3D scene |
796 | } |
841 | } |
797 | 842 | ||
798 | // else it's just the mouse wandering around ; have we the right to select something ? |
843 | // else it's just the mouse wandering around ; have we the right to select something ? |