51#define MAX_NODE_NAME_LEN 256
54static char _string[256];
58static int get_geometry_type(INode * node)
83 for (
int j=0; j<3; j++) {
84 Point3 row = newmat.GetRow(j);
86 if (fabs(row.x) <
EPSILON) row.x = 0.0f;
87 if (fabs(row.y) <
EPSILON) row.y = 0.0f;
88 if (fabs(row.z) <
EPSILON) row.z = 0.0f;
116 char *dot = strrchr(set_name,
'.');
121 if (sscanf(dot+1,
"%d", &
value) == 1)
124 else if (*(dot+1) == 0)
142void Split_Node_Name(
const char * name,
char * set_base,
char * set_exten,
int * set_exten_index)
154 if (set_base !=
NULL) set_base[0] = 0;
155 if (set_exten !=
NULL) set_exten[0] = 0;
156 if (set_exten_index !=
NULL) *set_exten_index = 0;
161 while ((*ptr != 0) && (*ptr !=
'.')) {
177 if (set_exten_index !=
NULL) *set_exten_index = atoi(ptr);
190 if (meshname ==
NULL || lod_level < 0)
203 INode *conflict =
NULL, *cur_origin =
NULL;
205 for (i = 0; i < num_lods; i++)
209 if (lod == lod_level)
218 int length = strlen(meshname);
223 char *insert = meshname + length;
224 *insert++ =
'0' + lod_level;
227 else if ( (lod_level < 100) && (length <
W3D_NAME_LEN - 2) )
232 sprintf(buf,
"%d", lod_level);
233 strcat(meshname, buf);
254 strcpy(full_path, curr);
255 int curr_len = strlen(curr);
256 char *full_p = full_path + curr_len;
257 if (curr_len == 0 ||(*(full_p - 1) !=
'/' && *(full_p - 1) !=
'\\')) {
259 *(++full_p) =
'\000';
265 for ( rel_p = rel_path;
266 *rel_p ==
'.' && *(rel_p+1) ==
'.' && ( *(rel_p+2) ==
'/' || *(rel_p+2) ==
'\\' );
270 for (; full_p > full_path && *(full_p-1) !=
'/' && *(full_p-1) !=
'\\'; full_p--);
275 strcpy(full_p, rel_p);
288 int curr_len = strlen(curr);
289 char *up_curr = (
char *)malloc(curr_len + 1);
290 strcpy(up_curr, curr);
293 int full_len = strlen(full_path);
294 char *up_full = (
char *)malloc(full_len + 1);
295 strcpy(up_full, full_path);
298 char *rel_p = rel_path;
301 const char *full_p = up_full;
302 const char *curr_p = up_curr;
304 *full_p && *full_p == *curr_p || (*full_p ==
'/' && *curr_p ==
'\\') || (*full_p ==
'\\' && *curr_p ==
'/');
310 if (full_p == up_full) {
318 if (*full_p ==
'\000') {
321 if (*full_p ==
'/' || *full_p ==
'\\') {
327 if (*curr_p ==
'\000') {
330 if (*curr_p ==
'/' || *curr_p ==
'\\') {
339 strcpy(rel_path, up_full);
348 strcpy(rel_path, full_p);
364 *(full_p-1) !=
'/' && *(full_p-1) !=
'\\') )
368 ( (*(full_p - 1) !=
'/' && *(full_p - 1) !=
'\\') ||
369 (*(curr_p - 1) !=
'/' && *(curr_p - 1) !=
'\\') );
375 if (full_p == up_full) {
376 strcpy(rel_path, up_full);
388 for (; *curr_p; curr_p++) {
389 if (*curr_p ==
'/' || *curr_p ==
'\\') {
398 if (*(curr_p - 1) ==
'/' || *(curr_p - 1) ==
'\\') {
403 strcpy(rel_p, full_p);
413 if (strchr(path,
':') !=
NULL) {
418 if ((path[0] ==
'/') && (path[1] ==
'/')) {
421 if ((path[0] ==
'\\') && (path[1] ==
'\\')) {
443 Object *obj = node->EvalWorldState(0).obj;
445 if (obj && obj->CanConvertToType(Class_ID(TRIOBJ_CLASS_ID, 0))) {
459 INode *parent = node->GetParentNode();
460 if (!parent || !parent->IsRootNode())
464 char *name = node->GetName();
465 if (strnicmp(name,
"damage.", strlen(
"damage.")) != 0)
497 if (!node)
return false;
498 if (node->IsRootNode())
return true;
499 if (node->IsHidden())
return false;
502 INode *parent = node->GetParentNode();
503 if (!parent || !parent->IsRootNode())
507 char *name = node->GetName();
508 if (strnicmp(name,
"origin.", strlen(
"origin.")) != 0)
537 if (!node)
return false;
539 if (node->IsRootNode())
return true;
546 bool is_base_origin =
false;
547 char *name = node->GetName();
548 if (stricmp(name,
"origin.") == 0)
549 is_base_origin =
true;
550 else if (strlen(name) > strlen(
"origin."))
555 if ((sscanf(name+strlen(
"origin."),
"%d", &idx) == 1) && (idx == 0))
556 is_base_origin =
true;
559 return is_base_origin;
565 if (node->IsRootNode())
return 0;
568 char *name = node->GetName();
569 char *dot = strrchr(name,
'.');
578 char *name = node->GetName();
579 char *dot = strrchr(name,
'.');
586 if (!root || !nodename)
597 if (strcmp(cur_name, nodename) == 0)
601 for (i = 0; i < root->NumChildren(); i++)
604 child = root->GetChildNode(i);
606 if (strcmp(nodename, cur_name) == 0)
611 for (i = 0; i < root->NumChildren(); i++)
613 child = root->GetChildNode(i);
Real Normalize(Real valueToNormalize, Real minRange, Real maxRange)
unsigned Num_Nodes(void) const
int Get_Geometry_Type(void) const
static W3DAppData2Struct * Get_App_Data(INode *node, bool create_if_missing=true)
bool Is_Base_Origin(INode *node)
int Get_Lod_Level(INode *node)
void Split_Node_Name(const char *name, char *set_base, char *set_exten, int *set_exten_index)
void Create_Relative_Path(char *rel_path, const char *curr, const char *full_path)
Matrix3 Cleanup_Orthogonal_Matrix(Matrix3 &mat)
void Set_W3D_Name(char *set_name, const char *src)
bool Is_Full_Path(char *path)
#define MAX_NODE_NAME_LEN
INode * Find_Named_Node(char *nodename, INode *root)
bool Is_Damage_Root(INode *node)
void Create_Full_Path(char *full_path, const char *curr, const char *rel_path)
bool Is_Origin(INode *node)
bool Is_Max_Tri_Mesh(INode *node)
bool Append_Lod_Character(char *meshname, int lod_level, INodeListClass *origin_list)
int Get_Damage_State(INode *node)