| 1 |
/* |
| 2 |
* Descent 3 |
| 3 |
* Copyright (C) 2024 Parallax Software |
| 4 |
* |
| 5 |
* This program is free software: you can redistribute it and/or modify |
| 6 |
* it under the terms of the GNU General Public License as published by |
| 7 |
* the Free Software Foundation, either version 3 of the License, or |
| 8 |
* (at your option) any later version. |
| 9 |
* |
| 10 |
* This program is distributed in the hope that it will be useful, |
| 11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 |
* GNU General Public License for more details. |
| 14 |
* |
| 15 |
* You should have received a copy of the GNU General Public License |
| 16 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 |
|
| 18 |
--- HISTORICAL COMMENTS FOLLOW --- |
| 19 |
|
| 20 |
* $Logfile: /DescentIII/Main/editor/EPath.cpp $ |
| 21 |
* $Revision: 1.1.1.1 $ |
| 22 |
* $Date: 2003-08-26 03:57:38 $ |
| 23 |
* $Author: kevinb $ |
| 24 |
* |
| 25 |
* Code to create & modify paths |
| 26 |
* |
| 27 |
* $Log: not supported by cvs2svn $ |
| 28 |
* |
| 29 |
* 13 8/20/99 9:43p Gwar |
| 30 |
* changes to InsertNodeIntoPath and DrawAllPaths for NEWEDITOR |
| 31 |
* |
| 32 |
* 12 8/18/99 7:00a Gwar |
| 33 |
* changes to add EPath.cpp to NEWEDITOR project |
| 34 |
* |
| 35 |
* 11 4/18/99 5:42a Chris |
| 36 |
* Added the FQ_IGNORE_RENDER_THROUGH_PORTALS flag |
| 37 |
* |
| 38 |
* 10 2/26/99 6:14p Matt |
| 39 |
* Made new nodes go at the viewer position instead of in front of it, and |
| 40 |
* make the selected path draw in a different color than the others. |
| 41 |
* |
| 42 |
* 9 2/26/99 12:40p Matt |
| 43 |
* Changed occluded messages to (hopefully) be more understandable |
| 44 |
* |
| 45 |
* 8 2/26/99 12:26p Matt |
| 46 |
* Fixed spelling error. |
| 47 |
* |
| 48 |
* 7 2/18/99 2:01p Dan |
| 49 |
* Fixed outside/inside problem |
| 50 |
* |
| 51 |
* 6 2/08/99 3:29p Chris |
| 52 |
* Added a no orient move for objects |
| 53 |
* |
| 54 |
* 5 2/03/99 6:56p Chris |
| 55 |
* Added the "Move node to current object" function |
| 56 |
* |
| 57 |
* 4 10/14/98 2:48p Kevin |
| 58 |
* Changed memory code to comply with mem lib |
| 59 |
* |
| 60 |
* 3 5/03/98 8:36p Chris |
| 61 |
* Additional debug info |
| 62 |
* |
| 63 |
* 2 2/10/98 10:48a Matt |
| 64 |
* Moved editor code from gamepath.cpp to epath.cpp |
| 65 |
* |
| 66 |
* 1 2/10/98 10:13a Matt |
| 67 |
* |
| 68 |
*/ |
| 69 |
|
| 70 |
#include <memory.h> |
| 71 |
|
| 72 |
#ifndef NEWEDITOR |
| 73 |
#include "d3edit.h" |
| 74 |
#else |
| 75 |
#include "globals.h" |
| 76 |
#include "terrain.h" |
| 77 |
#include "renderer.h" |
| 78 |
#endif |
| 79 |
|
| 80 |
#include "epath.h" |
| 81 |
|
| 82 |
#include "object.h" |
| 83 |
#include "findintersection.h" |
| 84 |
|
| 85 |
uint8_t Show_paths = 1; |
| 86 |
|
| 87 |
// Allocs a gamepath that a robot will follow. Returns an index into the GamePaths |
| 88 |
// array |
| 89 |
int AllocGamePath() { |
| 90 |
int i; |
| 91 |
|
| 92 |
if (Viewer_object->flags & OF_OUTSIDE_MINE) { |
| 93 |
OutrageMessageBox("You must be in a room or on the terrain to create a path"); |
| 94 |
return -1; |
| 95 |
} |
| 96 |
|
| 97 |
for (i = 0; i < MAX_GAME_PATHS; i++) { |
| 98 |
if (GamePaths[i].used == 0) { |
| 99 |
GamePaths[i].used = 1; |
| 100 |
GamePaths[i].name[0] = 0; |
| 101 |
GamePaths[i].num_nodes = 0; |
| 102 |
GamePaths[i].flags = 0; |
| 103 |
|
| 104 |
GamePaths[i].pathnodes = (node *)mem_malloc(MAX_NODES_PER_PATH * sizeof(node)); |
| 105 |
mprintf(0, "Path %d got some\n", i); |
| 106 |
|
| 107 |
Num_game_paths++; |
| 108 |
return i; |
| 109 |
} |
| 110 |
} |
| 111 |
|
| 112 |
OutrageMessageBox("ERROR: Too many paths to add another."); |
| 113 |
return -1; |
| 114 |
} |
| 115 |
|
| 116 |
int MovePathNode(int pathnum, int nodenum, vector *delta_pos) { |
| 117 |
vector attempted_pos = GamePaths[pathnum].pathnodes[nodenum].pos + *delta_pos; |
| 118 |
|
| 119 |
return MovePathNodeToPos(pathnum, nodenum, &attempted_pos); |
| 120 |
} |
| 121 |
|
| 122 |
int MovePathNodeToPos(int pathnum, int nodenum, vector *attempted_pos) { |
| 123 |
fvi_query fq; |
| 124 |
fvi_info hit_info; |
| 125 |
|
| 126 |
fq.p0 = &GamePaths[pathnum].pathnodes[nodenum].pos; |
| 127 |
fq.startroom = GamePaths[pathnum].pathnodes[nodenum].roomnum; |
| 128 |
fq.p1 = attempted_pos; |
| 129 |
fq.rad = 0.0f; |
| 130 |
fq.thisobjnum = -1; |
| 131 |
fq.ignore_obj_list = NULL; |
| 132 |
fq.flags = FQ_TRANSPOINT | FQ_IGNORE_RENDER_THROUGH_PORTALS; |
| 133 |
|
| 134 |
fvi_FindIntersection(&fq, &hit_info); |
| 135 |
|
| 136 |
// Check if new node is valid |
| 137 |
if (nodenum >= 1) { |
| 138 |
fvi_query fq1; |
| 139 |
fvi_info hit_info1; |
| 140 |
|
| 141 |
fq1.p0 = &GamePaths[pathnum].pathnodes[nodenum - 1].pos; |
| 142 |
fq1.startroom = GamePaths[pathnum].pathnodes[nodenum - 1].roomnum; |
| 143 |
fq1.p1 = &hit_info.hit_pnt; |
| 144 |
fq1.rad = 0.0f; |
| 145 |
fq1.thisobjnum = -1; |
| 146 |
fq1.ignore_obj_list = NULL; |
| 147 |
fq1.flags = FQ_TRANSPOINT | FQ_IGNORE_RENDER_THROUGH_PORTALS; |
| 148 |
|
| 149 |
fvi_FindIntersection(&fq1, &hit_info1); |
| 150 |
if (vm_VectorDistance(&hit_info.hit_pnt, &hit_info1.hit_pnt) > .005) { |
| 151 |
OutrageMessageBox("Cannot move point. There is no line of sight from the previous node to the new position."); |
| 152 |
return -1; |
| 153 |
} |
| 154 |
} |
| 155 |
|
| 156 |
// Check if new node is valid |
| 157 |
if (nodenum < GamePaths[pathnum].num_nodes - 1) { |
| 158 |
fvi_query fq1; |
| 159 |
fvi_info hit_info1; |
| 160 |
|
| 161 |
fq1.p0 = &GamePaths[pathnum].pathnodes[nodenum + 1].pos; |
| 162 |
fq1.startroom = GamePaths[pathnum].pathnodes[nodenum + 1].roomnum; |
| 163 |
fq1.p1 = &hit_info.hit_pnt; |
| 164 |
fq1.rad = 0.0f; |
| 165 |
fq1.thisobjnum = -1; |
| 166 |
fq1.ignore_obj_list = NULL; |
| 167 |
fq1.flags = FQ_TRANSPOINT | FQ_IGNORE_RENDER_THROUGH_PORTALS; |
| 168 |
|
| 169 |
fvi_FindIntersection(&fq1, &hit_info1); |
| 170 |
if (vm_VectorDistance(&hit_info.hit_pnt, &hit_info1.hit_pnt) > .005) { |
| 171 |
OutrageMessageBox("Cannot move point. There is no line of sight from the next node to the new position."); |
| 172 |
return -1; |
| 173 |
} |
| 174 |
} |
| 175 |
|
| 176 |
GamePaths[pathnum].pathnodes[nodenum].pos = hit_info.hit_pnt; |
| 177 |
GamePaths[pathnum].pathnodes[nodenum].roomnum = hit_info.hit_room; |
| 178 |
|
| 179 |
return 0; |
| 180 |
} |
| 181 |
|
| 182 |
// Given a path number, and a node number in that path, adds another node after the |
| 183 |
// specified node |
| 184 |
// Returns the index number of the new node |
| 185 |
// If nodenum is -1, this node was not added |
| 186 |
// roomnum is only valid if this is the first node in a room |
| 187 |
#ifndef NEWEDITOR |
| 188 |
int InsertNodeIntoPath(int pathnum, int nodenum, int flags) |
| 189 |
#else |
| 190 |
int InsertNodeIntoPath(int pathnum, int nodenum, int flags, int roomnum, vector pos, matrix orient) |
| 191 |
#endif |
| 192 |
{ |
| 193 |
int i; |
| 194 |
vector attempted_pos; |
| 195 |
|
| 196 |
fvi_query fq; |
| 197 |
fvi_info hit_info; |
| 198 |
|
| 199 |
if (Viewer_object->flags & OF_OUTSIDE_MINE) { |
| 200 |
OutrageMessageBox("Error: Must be in mine or on terrain to insert a node."); |
| 201 |
return -1; |
| 202 |
} |
| 203 |
|
| 204 |
if (GamePaths[pathnum].num_nodes >= MAX_NODES_PER_PATH) { |
| 205 |
OutrageMessageBox("Error: Path already has its maximum amount of nodes."); |
| 206 |
return -1; |
| 207 |
} |
| 208 |
|
| 209 |
// First, move all nodes up one |
| 210 |
for (i = GamePaths[pathnum].num_nodes - 1; i > nodenum; i--) { |
| 211 |
memcpy(&GamePaths[pathnum].pathnodes[i + 1], &GamePaths[pathnum].pathnodes[i], sizeof(node)); |
| 212 |
} |
| 213 |
|
| 214 |
#ifndef NEWEDITOR |
| 215 |
attempted_pos = Viewer_object->pos; // + Viewer_object->orient.fvec * 10.0; |
| 216 |
#else |
| 217 |
attempted_pos = pos; // + Viewer_object->orient.fvec * 10.0; |
| 218 |
#endif |
| 219 |
|
| 220 |
#ifndef NEWEDITOR |
| 221 |
fq.p0 = &Viewer_object->pos; |
| 222 |
fq.startroom = Viewer_object->roomnum; |
| 223 |
#else |
| 224 |
fq.p0 = &pos; |
| 225 |
fq.startroom = roomnum; |
| 226 |
#endif |
| 227 |
fq.p1 = &attempted_pos; |
| 228 |
fq.rad = 0.0f; |
| 229 |
fq.thisobjnum = -1; |
| 230 |
fq.ignore_obj_list = NULL; |
| 231 |
fq.flags = FQ_TRANSPOINT | FQ_IGNORE_RENDER_THROUGH_PORTALS; |
| 232 |
|
| 233 |
fvi_FindIntersection(&fq, &hit_info); |
| 234 |
|
| 235 |
// Check if new node is valid |
| 236 |
if (nodenum >= 0) { |
| 237 |
fvi_query fq1; |
| 238 |
fvi_info hit_info1; |
| 239 |
|
| 240 |
fq1.p0 = &GamePaths[pathnum].pathnodes[nodenum].pos; |
| 241 |
fq1.startroom = GamePaths[pathnum].pathnodes[nodenum].roomnum; |
| 242 |
fq1.p1 = &hit_info.hit_pnt; |
| 243 |
fq1.rad = 0.0f; |
| 244 |
fq1.thisobjnum = -1; |
| 245 |
fq1.ignore_obj_list = NULL; |
| 246 |
fq1.flags = FQ_TRANSPOINT | FQ_IGNORE_RENDER_THROUGH_PORTALS; |
| 247 |
|
| 248 |
fvi_FindIntersection(&fq1, &hit_info1); |
| 249 |
if (vm_VectorDistance(&hit_info.hit_pnt, &hit_info1.hit_pnt) > .005) { |
| 250 |
OutrageMessageBox("Cannot add new point. There is no line of sight from the previous node."); |
| 251 |
return -1; |
| 252 |
} |
| 253 |
} |
| 254 |
|
| 255 |
// Check if new node is valid |
| 256 |
if (nodenum >= 0 && nodenum < GamePaths[pathnum].num_nodes - 1) { |
| 257 |
fvi_query fq1; |
| 258 |
fvi_info hit_info1; |
| 259 |
|
| 260 |
fq1.p0 = &GamePaths[pathnum].pathnodes[nodenum + 1].pos; |
| 261 |
fq1.startroom = GamePaths[pathnum].pathnodes[nodenum + 1].roomnum; |
| 262 |
fq1.p1 = &hit_info.hit_pnt; |
| 263 |
fq1.rad = 0.0f; |
| 264 |
fq1.thisobjnum = -1; |
| 265 |
fq1.ignore_obj_list = NULL; |
| 266 |
fq1.flags = FQ_TRANSPOINT | FQ_IGNORE_RENDER_THROUGH_PORTALS; |
| 267 |
|
| 268 |
fvi_FindIntersection(&fq1, &hit_info1); |
| 269 |
if (vm_VectorDistance(&hit_info.hit_pnt, &hit_info1.hit_pnt) > .005) { |
| 270 |
OutrageMessageBox("Cannot add new point. There is no line of sight from the next node."); |
| 271 |
return -1; |
| 272 |
} |
| 273 |
} |
| 274 |
|
| 275 |
int newnode = nodenum + 1; |
| 276 |
|
| 277 |
GamePaths[pathnum].pathnodes[newnode].pos = hit_info.hit_pnt; |
| 278 |
GamePaths[pathnum].pathnodes[newnode].roomnum = hit_info.hit_room; |
| 279 |
|
| 280 |
#ifndef NEWEDITOR |
| 281 |
GamePaths[pathnum].pathnodes[newnode].fvec = Viewer_object->orient.fvec; |
| 282 |
GamePaths[pathnum].pathnodes[newnode].uvec = Viewer_object->orient.uvec; |
| 283 |
#else |
| 284 |
GamePaths[pathnum].pathnodes[newnode].fvec = orient.fvec; |
| 285 |
GamePaths[pathnum].pathnodes[newnode].uvec = orient.uvec; |
| 286 |
#endif |
| 287 |
|
| 288 |
GamePaths[pathnum].num_nodes++; |
| 289 |
|
| 290 |
GamePaths[pathnum].pathnodes[newnode].flags = flags; |
| 291 |
|
| 292 |
return newnode; |
| 293 |
} |
| 294 |
|
| 295 |
// Given a pathnum and a node index, deletes that node and moves all the following nodes down |
| 296 |
// by one |
| 297 |
void DeleteNodeFromPath(int pathnum, int nodenum) { |
| 298 |
int i; |
| 299 |
|
| 300 |
// First, move all nodes up one |
| 301 |
for (i = nodenum; i < GamePaths[pathnum].num_nodes - 1; i++) { |
| 302 |
memcpy(&GamePaths[pathnum].pathnodes[i], &GamePaths[pathnum].pathnodes[i + 1], sizeof(node)); |
| 303 |
} |
| 304 |
|
| 305 |
GamePaths[pathnum].num_nodes--; |
| 306 |
} |
| 307 |
|
| 308 |
// Gets next path from n that has actually been alloced |
| 309 |
int GetNextPath(int n) { |
| 310 |
int i; |
| 311 |
|
| 312 |
ASSERT(n >= 0 && n < MAX_GAME_PATHS); |
| 313 |
|
| 314 |
if (Num_game_paths == 0) |
| 315 |
return -1; |
| 316 |
|
| 317 |
for (i = n + 1; i < MAX_GAME_PATHS; i++) |
| 318 |
if (GamePaths[i].used) |
| 319 |
return i; |
| 320 |
for (i = 0; i < n; i++) |
| 321 |
if (GamePaths[i].used) |
| 322 |
return i; |
| 323 |
|
| 324 |
// this is the only one |
| 325 |
|
| 326 |
return n; |
| 327 |
} |
| 328 |
|
| 329 |
// Gets previous path from n that has actually been alloced |
| 330 |
int GetPrevPath(int n) { |
| 331 |
int i; |
| 332 |
|
| 333 |
ASSERT(n >= 0 && n < MAX_GAME_PATHS); |
| 334 |
|
| 335 |
if (Num_game_paths == 0) |
| 336 |
return -1; |
| 337 |
|
| 338 |
for (i = n - 1; i >= 0; i--) { |
| 339 |
if (GamePaths[i].used) |
| 340 |
return i; |
| 341 |
} |
| 342 |
for (i = MAX_GAME_PATHS - 1; i > n; i--) { |
| 343 |
if (GamePaths[i].used) |
| 344 |
return i; |
| 345 |
} |
| 346 |
|
| 347 |
// this is the only one |
| 348 |
return n; |
| 349 |
} |
| 350 |
|
| 351 |
// returns the index of the first path (from 0) alloced |
| 352 |
// returns -1 if there are no paths |
| 353 |
int GetFirstPath() { |
| 354 |
int i; |
| 355 |
for (i = 0; i < MAX_GAME_PATHS; i++) { |
| 356 |
if (GamePaths[i].used) |
| 357 |
return i; |
| 358 |
} |
| 359 |
return -1; |
| 360 |
} |
| 361 |
|
| 362 |
#ifndef NEWEDITOR |
| 363 |
#include "editor/d3edit.h" |
| 364 |
#endif |
| 365 |
|
| 366 |
#include "gr.h" |
| 367 |
|
| 368 |
void DrawAllPaths(grViewport *vp, vector *viewer_eye, matrix *viewer_orient, float zoom) { |
| 369 |
int i, current_path_index = 0, t; |
| 370 |
g3Point rot_points[300]; |
| 371 |
int sort_index[300]; |
| 372 |
|
| 373 |
if (!Show_paths) |
| 374 |
return; |
| 375 |
|
| 376 |
current_path_index = GetFirstPath(); |
| 377 |
|
| 378 |
for (i = 0; i < Num_game_paths; i++, current_path_index = GetNextPath(current_path_index)) { |
| 379 |
|
| 380 |
game_path *gp = &GamePaths[current_path_index]; |
| 381 |
|
| 382 |
#ifndef NEWEDITOR |
| 383 |
int curnode = D3EditState.current_node; |
| 384 |
#else |
| 385 |
int curnode = Editor_state.GetCurrentNode(); |
| 386 |
#endif |
| 387 |
|
| 388 |
for (t = 0; t < gp->num_nodes; t++) { |
| 389 |
g3_RotatePoint(&rot_points[t], &gp->pathnodes[t].pos); |
| 390 |
sort_index[t] = t; |
| 391 |
} |
| 392 |
|
| 393 |
#ifndef NEWEDITOR |
| 394 |
ddgr_color path_color = |
| 395 |
(current_path_index == D3EditState.current_path) ? GR_RGB(255, 255, 255) : GR_RGB(36, 99, 238); |
| 396 |
#else |
| 397 |
ddgr_color path_color = |
| 398 |
(current_path_index == Editor_state.GetCurrentPath()) ? GR_RGB(255, 255, 255) : GR_RGB(36, 99, 238); |
| 399 |
#endif |
| 400 |
|
| 401 |
for (t = 0; t < gp->num_nodes - 1; t++) { |
| 402 |
g3Point p1 = rot_points[t]; |
| 403 |
g3Point p2 = rot_points[t + 1]; |
| 404 |
|
| 405 |
g3_DrawLine(path_color, &p1, &p2); |
| 406 |
} |
| 407 |
|
| 408 |
for (t = 0; t < gp->num_nodes; t++) { |
| 409 |
for (int k = 0; k < gp->num_nodes; k++) { |
| 410 |
if (rot_points[k].p3_vec.z < rot_points[t].p3_vec.z) { |
| 411 |
g3Point temp; |
| 412 |
int tindex; |
| 413 |
|
| 414 |
memcpy(&temp, &rot_points[t], sizeof(g3Point)); |
| 415 |
memcpy(&rot_points[t], &rot_points[k], sizeof(g3Point)); |
| 416 |
memcpy(&rot_points[k], &temp, sizeof(g3Point)); |
| 417 |
|
| 418 |
tindex = sort_index[t]; |
| 419 |
sort_index[t] = sort_index[k]; |
| 420 |
sort_index[k] = tindex; |
| 421 |
} |
| 422 |
} |
| 423 |
} |
| 424 |
|
| 425 |
for (t = 0; t < gp->num_nodes; t++) { |
| 426 |
int color; |
| 427 |
float size; |
| 428 |
|
| 429 |
#ifdef NEWEDITOR |
| 430 |
ddgr_color oldcolor; |
| 431 |
|
| 432 |
if (TSearch_on) { |
| 433 |
rend_SetPixel(GR_RGB(16, 255, 16), TSearch_x, TSearch_y); |
| 434 |
oldcolor = rend_GetPixel(TSearch_x, TSearch_y); |
| 435 |
} |
| 436 |
#endif |
| 437 |
|
| 438 |
#ifndef NEWEDITOR |
| 439 |
if (current_path_index == D3EditState.current_path && curnode == sort_index[t]) |
| 440 |
#else |
| 441 |
if (current_path_index == Editor_state.GetCurrentPath() && curnode == sort_index[t]) |
| 442 |
#endif |
| 443 |
{ |
| 444 |
color = GR_RGB(100, 128, 255); |
| 445 |
size = 1.2f; |
| 446 |
} else { |
| 447 |
color = GR_RGB(0, 128, 160); |
| 448 |
size = 1.2f; |
| 449 |
} |
| 450 |
|
| 451 |
g3_DrawSphere(color, &rot_points[t], size); |
| 452 |
|
| 453 |
vector fpos = gp->pathnodes[sort_index[t]].pos + gp->pathnodes[sort_index[t]].fvec * (size - size / 10.0); |
| 454 |
vector upos = gp->pathnodes[sort_index[t]].pos + gp->pathnodes[sort_index[t]].uvec * (size - size / 10.0); |
| 455 |
|
| 456 |
g3Point frot; |
| 457 |
g3Point urot; |
| 458 |
|
| 459 |
g3_RotatePoint(&frot, &fpos); |
| 460 |
g3_RotatePoint(&urot, &upos); |
| 461 |
|
| 462 |
g3_DrawLine(GR_RGB(0, 255, 0), &rot_points[t], &frot); |
| 463 |
g3_DrawLine(GR_RGB(0, 0, 255), &rot_points[t], &urot); |
| 464 |
g3_DrawSphere(GR_RGB(0, 255, 0), &frot, size / 10.0); |
| 465 |
g3_DrawSphere(GR_RGB(0, 0, 255), &urot, size / 10.0); |
| 466 |
|
| 467 |
#ifdef NEWEDITOR |
| 468 |
if (TSearch_on) { |
| 469 |
if (rend_GetPixel(TSearch_x, TSearch_y) != oldcolor) { |
| 470 |
TSearch_found_type = TSEARCH_FOUND_NODE; |
| 471 |
TSearch_seg = current_path_index; |
| 472 |
TSearch_face = sort_index[t]; |
| 473 |
} |
| 474 |
} |
| 475 |
#endif |
| 476 |
|
| 477 |
DrawNumber(sort_index[t] + 1, gp->pathnodes[sort_index[t]].pos, size * .5); |
| 478 |
} |
| 479 |
} |
| 480 |
} |
| 481 |
|
| 482 |
static float ArrayX[10][20] = {{-1, 1, 1, -1, -1}, |
| 483 |
{-.25, 0.0, 0.0, 0.0, -1.0, 1.0}, |
| 484 |
{-1.0, 1.0, 1.0, 1.0, -1.0, 1.0, -1.0, -1.0, -1.0, 1.0}, |
| 485 |
{-1.0, 1.0, 1.0, -1.0, 1.0, 1.0, -.5}, |
| 486 |
{-1.0, -1.0, -1.0, 1.0, 1.0, 1.0}, |
| 487 |
{-1.0, 1.0, -1.0, -1.0, -1.0, 1.0, 1.0, 1.0, -1.0, 1.0}, |
| 488 |
{-1.0, 1.0, -1.0, -1.0, -1.0, 1.0, 1.0, 1.0, -1.0, 1.0}, |
| 489 |
{-1.0, 1.0, 1.0, 1.0}, |
| 490 |
{-1.0, 1.0, 1.0, 1.0, -1.0, 1.0, -1.0, -1.0, -1.0, 1.0}, |
| 491 |
{1.0, -1.0, -1.0, 1.0, 1.0, 1.0}}; |
| 492 |
|
| 493 |
static float ArrayY[10][20] = {{1, 1, -1, -1, 1}, |
| 494 |
{.75, 1.0, 1.0, -1.0, -1.0, -1.0}, |
| 495 |
{1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, -1.0, -1.0, -1.0}, |
| 496 |
{1.0, 1.0, -1.0, -1.0, -1.0, 0, 0.0}, |
| 497 |
{1.0, 0.0, 0.0, 0.0, 1.0, -1.0}, |
| 498 |
{1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, -1.0, -1.0, -1.0}, |
| 499 |
{1.0, 1.0, 1.0, -1.0, -1.0, -1.0, -1.0, 0.0, 0.0, 0.0}, |
| 500 |
{1.0, 1.0, 1.0, -1.0}, |
| 501 |
{1.0, 1.0, 1.0, -1.0, -1.0, -1.0, -1.0, 1.0, 0.0, 0.0}, |
| 502 |
{1.0, 1.0, 0.0, 0.0, 1.0, -1.0}}; |
| 503 |
|
| 504 |
static int NumOfPoints[] = {5, 6, 10, 7, 6, 10, 10, 4, 10, 6}; |
| 505 |
|
| 506 |
void DrawNumber(int num, vector pos, float size) { |
| 507 |
g3Point basepnt, rot_pnt[20]; |
| 508 |
int num_array[10]; |
| 509 |
int i, j; |
| 510 |
int total = num; |
| 511 |
size /= 2; |
| 512 |
|
| 513 |
if (num < 0) { |
| 514 |
return; |
| 515 |
} |
| 516 |
|
| 517 |
int num_numbers = log10(num) + 1; |
| 518 |
if (num_numbers > 10) { |
| 519 |
mprintf(0, "Cannot represent a number with over 10 digits\n"); |
| 520 |
Int3(); |
| 521 |
return; |
| 522 |
} |
| 523 |
|
| 524 |
for (j = num_numbers - 1; j >= 0; j--) { |
| 525 |
num_array[j] = total / (pow(10, j)); |
| 526 |
total -= num_array[j] * pow(10, j); |
| 527 |
} |
| 528 |
|
| 529 |
for (j = 0; j < num_numbers; j++) { |
| 530 |
vector cur_pos; |
| 531 |
|
| 532 |
if (num_numbers & 0x00000001) |
| 533 |
cur_pos = pos + (2.1 * size * ((num_numbers >> 1) - j)) * Viewer_object->orient.rvec; |
| 534 |
else |
| 535 |
cur_pos = pos + (2.1 * size * ((num_numbers >> 1) - j) - size) * Viewer_object->orient.rvec; |
| 536 |
|
| 537 |
g3_RotatePoint(&basepnt, &cur_pos); |
| 538 |
|
| 539 |
for (i = 0; i < NumOfPoints[num_array[j]]; i++) { |
| 540 |
rot_pnt[i] = basepnt; |
| 541 |
|
| 542 |
rot_pnt[i].p3_vec.x += (ArrayX[num_array[j]][i] * size); |
| 543 |
rot_pnt[i].p3_vec.y += (ArrayY[num_array[j]][i] * size); |
| 544 |
|
| 545 |
rot_pnt[i].p3_flags = 0; |
| 546 |
g3_CodePoint(&rot_pnt[i]); |
| 547 |
g3_ProjectPoint(&rot_pnt[i]); |
| 548 |
} |
| 549 |
|
| 550 |
for (i = 0; i < NumOfPoints[num_array[j]] - 1; i++) { |
| 551 |
g3Point p1, p2; |
| 552 |
|
| 553 |
p1 = rot_pnt[i]; |
| 554 |
p2 = rot_pnt[i + 1]; |
| 555 |
|
| 556 |
g3_DrawLine(GR_RGB(255, 255, 255), &p1, &p2); |
| 557 |
} |
| 558 |
} |
| 559 |
} |