void build_bone_list_from_nodes(struct aiNode *node, int parent, char *clean_name) { int i; // inherit clean names for auto-inserted nodes if (!strstr(node->mName.data, "$ColladaAutoName$")) clean_name = clean_node_name((char*)node->mName.data); bonelist[numbones].name = node->mName.data; bonelist[numbones].clean_name = clean_name; bonelist[numbones].parent = parent; bonelist[numbones].reason = "<none>"; bonelist[numbones].isbone = 0; bonelist[numbones].isskin = 0; bonelist[numbones].isrigid = 0; bonelist[numbones].node = node; // these are set in calc_bind_pose and/or apply_initial_frame aiIdentityMatrix4(&bonelist[numbones].pose); aiIdentityMatrix4(&bonelist[numbones].abspose); aiIdentityMatrix4(&bonelist[numbones].invpose); parent = numbones++; for (i = 0; i < node->mNumChildren; i++) build_bone_list_from_nodes(node->mChildren[i], parent, clean_name); }
static uint64_t get_guid_for_name(nn_map_t * map, char *name) { cl_map_item_t *map_item = NULL; for (map_item = cl_qmap_head(map); map_item != cl_qmap_end(map); map_item = cl_qmap_next(map_item)) { name_map_item_t *item = (name_map_item_t *)map_item; char *iname = item->name; if (skummee_output) { char tmp[256]; strncpy(tmp, item->name, 256); clean_node_name(tmp); iname = tmp; } if (strcmp(iname, name) == 0) return (item->guid); } return (0); }
void export_node(FILE *out, const struct aiScene *scene, const struct aiNode *node, struct aiMatrix4x4 mat, char *clean_name) { struct aiMatrix3x3 mat3; int i, a, k, t; aiMultiplyMatrix4(&mat, &node->mTransformation); mat3.a1 = mat.a1; mat3.a2 = mat.a2; mat3.a3 = mat.a3; mat3.b1 = mat.b1; mat3.b2 = mat.b2; mat3.b3 = mat.b3; mat3.c1 = mat.c1; mat3.c2 = mat.c2; mat3.c3 = mat.c3; if (!strstr(node->mName.data, "$ColladaAutoName$")) clean_name = clean_node_name((char*)node->mName.data); if (only_one_node && strcmp(clean_name, only_one_node)) goto skip_mesh; for (i = 0; i < node->mNumMeshes; i++) { struct aiMesh *mesh = scene->mMeshes[node->mMeshes[i]]; struct aiMaterial *material = scene->mMaterials[mesh->mMaterialIndex]; if (mesh->mNumBones == 0 && dobone && !dorigid) { if (verbose) fprintf(stderr, "skipping rigid mesh %d in node %s (no bones)\n", i, clean_name); continue; } fprintf(stderr, "exporting mesh %s[%d]: %d vertices, %d faces\n", clean_name, i, mesh->mNumVertices, mesh->mNumFaces); fprintf(out, "\n"); fprintf(out, "mesh \"%s\"\n", clean_name); fprintf(out, "material \"%s\"\n", find_material(material)); struct vb *vb = (struct vb*) malloc(mesh->mNumVertices * sizeof(*vb)); memset(vb, 0, mesh->mNumVertices * sizeof(*vb)); // A rigidly animated node -- insert fake blend index/weights if (mesh->mNumBones == 0 && dobone) { a = find_bone((char*)node->mName.data); if (verbose) fprintf(stderr, "\trigid bone %d for mesh in node %s (no bones)\n", bonelist[a].number, node->mName.data); for (k = 0; k < mesh->mNumVertices; k++) { vb[k].b[0] = bonelist[a].number; vb[k].w[0] = 1; vb[k].n = 1; } } // Assemble blend index/weight array for (k = 0; k < mesh->mNumBones; k++) { struct aiBone *bone = mesh->mBones[k]; a = find_bone(bone->mName.data); for (t = 0; t < bone->mNumWeights; t++) { struct aiVertexWeight *w = mesh->mBones[k]->mWeights + t; int idx = w->mVertexId; if (vb[idx].n < MAXBLEND) { vb[idx].b[vb[idx].n] = bonelist[a].number; vb[idx].w[vb[idx].n] = w->mWeight; vb[idx].n++; } } } for (k = 0; k < mesh->mNumVertices; k++) { struct aiVector3D vp = mesh->mVertices[k]; if (!dobone) aiTransformVecByMatrix4(&vp, &mat); fprintf(out, "vp %.9g %.9g %.9g\n", vp.x, vp.y, vp.z); if (mesh->mNormals) { struct aiVector3D vn = mesh->mNormals[k]; if (!dobone) aiTransformVecByMatrix3(&vn, &mat3); fprintf(out, "vn %.9g %.9g %.9g\n", vn.x, vn.y, vn.z); } if (mesh->mTextureCoords[0]) { float u = mesh->mTextureCoords[0][k].x; float v = 1 - mesh->mTextureCoords[0][k].y; fprintf(out, "vt %.9g %.9g\n", u, v); } for (t = 1; t <= MAX_UVMAP; t++) { if (mesh->mTextureCoords[t]) { float u = mesh->mTextureCoords[t][k].x; float v = 1 - mesh->mTextureCoords[t][k].y; fprintf(out, "v%d %.9g %.9g\n", FIRST_UVMAP+t-1, u, v); } } if (mesh->mColors[0]) { float r = mesh->mColors[0][k].r; r = floorf(r * 255) / 255; float g = mesh->mColors[0][k].g; g = floorf(g * 255) / 255; float b = mesh->mColors[0][k].b; b = floorf(b * 255) / 255; float a = mesh->mColors[0][k].a; a = floorf(a * 255) / 255; fprintf(out, "vc %.9g %.9g %.9g %.9g\n", r, g, b, a); } for (t = 1; t <= MAX_COL; t++) { if (mesh->mColors[t]) { float r = mesh->mColors[t][k].r; r = floorf(r * 255) / 255; float g = mesh->mColors[t][k].g; g = floorf(g * 255) / 255; float b = mesh->mColors[t][k].b; b = floorf(b * 255) / 255; float a = mesh->mColors[t][k].a; a = floorf(a * 255) / 255; fprintf(out, "v%d %.9g %.9g %.9g %.9g\n", FIRST_COL+t-1, r, g, b, a); } } if (dobone) { fprintf(out, "vb"); for (t = 0; t < vb[k].n; t++) { fprintf(out, " %d %.9g", vb[k].b[t], vb[k].w[t]); } fprintf(out, "\n"); } } for (k = 0; k < mesh->mNumFaces; k++) { struct aiFace *face = mesh->mFaces + k; if (face->mNumIndices == 3) { if (doflip) fprintf(out, "fm %d %d %d\n", face->mIndices[2], face->mIndices[1], face->mIndices[0]); else fprintf(out, "fm %d %d %d\n", face->mIndices[0], face->mIndices[1], face->mIndices[2]); } else if (face->mNumIndices == 4) { if (doflip) fprintf(out, "fm %d %d %d %d\n", face->mIndices[3], face->mIndices[2], face->mIndices[1], face->mIndices[0]); else fprintf(out, "fm %d %d %d %d\n", face->mIndices[0], face->mIndices[1], face->mIndices[2], face->mIndices[3]); } else if (face->mNumIndices > 4) { fprintf(stderr, "n-gon (%d) in mesh!\n", face->mNumIndices); int i1 = face->mIndices[0]; int i2 = face->mIndices[1]; for (a = 2; a < face->mNumIndices; a++) { int i3 = face->mIndices[a]; if (doflip) fprintf(out, "fm %d %d %d\n", i3, i2, i1); else fprintf(out, "fm %d %d %d\n", i1, i2, i3); i2 = i3; } } else { fprintf(stderr, "skipping point/line primitive\n"); } } free(vb); } skip_mesh: for (i = 0; i < node->mNumChildren; i++) export_node(out, scene, node->mChildren[i], mat, clean_name); }
/** ========================================================================= * Port <= 0 indicates "all" ports */ static int report(mysql_connection_t *conn, char *node, int port) { int rc = 0; unsigned int num_fields; unsigned int num_rows, i; MYSQL_RES *res; MYSQL_ROW row; #define CLAUSE_SIZE (256) char node_clause[CLAUSE_SIZE]; char port_clause[CLAUSE_SIZE]; if (node) { /* check to see if the node is specified by name or guid */ uint64_t guid = strtoull(node, NULL, 0); if (guid == 0) guid = get_guid_for_name(node_name_map, node); if (guid == 0) { snprintf(node_clause, CLAUSE_SIZE, " and n.name=\"%s\"", node); } else { snprintf(node_clause, CLAUSE_SIZE, " and n.guid=%"PRIuLEAST64, guid); } } else { node_clause[0] = '\0'; } if (port > 0) { snprintf(port_clause, CLAUSE_SIZE, " and pe.port=%d", port); } else { port_clause[0] = '\0'; } if (QUERY(conn, "select pe.SymbolErrors, pe.LinkRecovers," " pe.LinkDowned, pe.RcvErrors, pe.RcvRemotePhysErrors," " pe.RcvSwitchRelayErrors, pe.XmtDiscards," " pe.XmtConstraintErrors, pe.RcvConstraintErrors," " pe.LinkIntegrityErrors, pe.ExcBufOverrunErrors," " pe.VL15Dropped, n.name, pe.port, n.guid," " pd.xmit_data, pd.rcv_data, pd.xmit_pkts, pd.rcv_pkts," " pd.unicast_xmit_pkts, pd.unicast_rcv_pkts," " pd.multicast_xmit_pkts, pd.multicast_rcv_pkts, " " pd.port " " from " " port_errors as pe,nodes as n,port_data_counters as pd " " where" " n.guid=pe.guid and n.guid=pd.guid and pe.port=pd.port %s %s;", node_clause, port_clause)) { fprintf(stderr, "Failed to query node errors"); if (node) { fprintf(stderr, " for \"%s\"", node); } else { fprintf(stderr, "\n"); } return (1); } res = mysql_store_result(conn->conn); if ((num_fields = mysql_num_fields(res)) != 24) { fprintf(stderr, "%s:%d Failed to query node errors %d != 24\n", __FUNCTION__, __LINE__, num_fields); rc = 1; goto free_res; } num_rows = mysql_num_rows(res); if (num_rows == 0) { if (node) { if (port <= 0) { fprintf(stderr, "Node \"%s\" (port %s) not found in DB\n", node, "\"all\""); } else { fprintf(stderr, "Node \"%s\" (port %d) not found in DB\n", node, port); } } else { fprintf(stderr, "Failed to find any nodes in DB\n"); } rc = 1; goto free_res; } for (i = 0; i < num_rows; i++) { char node_desc[65]; char *node_name = NULL; row = mysql_fetch_row(res); strncpy(node_desc, row[12], 64); node_name = remap_node_name(node_name_map, COL_TO_UINT64(14), node_desc); if (skummee_output) { clean_node_name(node_name); print_report_line_res(node_name, row); } else print_report_res(node_name, row); free(node_name); } free_res: mysql_free_result(res); return (rc); }
static int query_status(mysql_connection_t *conn) { int rc = 0; unsigned int num_fields; unsigned int num_rows, i; uint64_t errors = 0; MYSQL_RES *res; MYSQL_ROW row; #if HAVE_LIBGENDERS genders_t genders_handle; char **nodes = NULL; int num_nodes = 0; switch_error_sum_t switch_error_sum; memset(&switch_error_sum, 0, (sizeof switch_error_sum)); #endif /* issue the query join for any errors */ if (QUERY(conn, "select pe.SymbolErrors, pe.LinkRecovers," " pe.LinkDowned, pe.RcvErrors, pe.RcvRemotePhysErrors," " pe.RcvSwitchRelayErrors, pe.XmtDiscards," " pe.XmtConstraintErrors, pe.RcvConstraintErrors," " pe.LinkIntegrityErrors, pe.ExcBufOverrunErrors," " pe.VL15Dropped, n.name, pe.port, n.guid" " from port_errors as pe,nodes as n where n.guid=pe.guid;")) { fprintf(stderr, "Failed to query node errors\n"); return (1); } res = mysql_store_result(conn->conn); if ((num_fields = mysql_num_fields(res)) != 15) { fprintf(stderr, "%s:%d Failed to query status %d != 14\n", __FUNCTION__, __LINE__, num_fields); rc = 1; goto free_res; } num_rows = mysql_num_rows(res); #if HAVE_LIBGENDERS genders_handle = genders_handle_create(); if (!genders_handle || genders_load_data(genders_handle, NULL)) { fprintf(stderr, "Genders load failed: %s\n", genders_handle ? genders_errormsg(genders_handle) : "handle creation failed"); goto genders_open_fail; } #endif /* The basic algo is to sum up all the errors and report them together */ for (i = 0; i < num_rows; i++) { char node_desc[65]; char *node_name = NULL; row = mysql_fetch_row(res); /* add up all the errors reported. */ errors = 0; errors += COL_TO_UINT64(0); errors += COL_TO_UINT64(1); errors += COL_TO_UINT64(2); errors += COL_TO_UINT64(3); errors += COL_TO_UINT64(4); errors += COL_TO_UINT64(5); errors += COL_TO_UINT64(6); errors += COL_TO_UINT64(7); errors += COL_TO_UINT64(8); errors += COL_TO_UINT64(9); errors += COL_TO_UINT64(10); errors += COL_TO_UINT64(11); #if HAVE_LIBGENDERS if (sum_fabric_errors && !genders_isnode(genders_handle, row[12])) { switch_error_sum.SymbolErrors += COL_TO_UINT64(0); switch_error_sum.LinkRecovers += COL_TO_UINT64(1); switch_error_sum.LinkDowned += COL_TO_UINT64(2); switch_error_sum.RcvErrors += COL_TO_UINT64(3); switch_error_sum.RcvRemotePhysErrors += COL_TO_UINT64(4); switch_error_sum.RcvSwitchRelayErrors += COL_TO_UINT64(5); switch_error_sum.XmtDiscards += COL_TO_UINT64(6); switch_error_sum.XmtConstraintErrors += COL_TO_UINT64(7); switch_error_sum.RcvConstraintErrors += COL_TO_UINT64(8); switch_error_sum.LinkIntegrityErrors += COL_TO_UINT64(9); switch_error_sum.ExcBufOverrunErrors += COL_TO_UINT64(10); switch_error_sum.VL15Dropped += COL_TO_UINT64(11); } #endif strncpy(node_desc, row[12], 64); node_name = remap_node_name(node_name_map, COL_TO_UINT64(14), node_desc); clean_node_name(node_name); printf("%s,ibport%s-error_sum,%"PRIuLEAST64"\n", node_name, row[13], errors); free(node_name); } #if HAVE_LIBGENDERS if (sum_fabric_errors) { printf("%s,SymbolErrors_sum,%"PRIuLEAST64"\n", IB_SWITCH_TOTAL_NODE_NAME, switch_error_sum.SymbolErrors); printf("%s,SymbolErrors_sum_counter,%"PRIuLEAST64"\n", IB_SWITCH_TOTAL_NODE_NAME, switch_error_sum.SymbolErrors); printf("%s,LinkRecovers_sum,%"PRIuLEAST64"\n", IB_SWITCH_TOTAL_NODE_NAME, switch_error_sum.LinkRecovers); printf("%s,LinkRecovers_sum_counter,%"PRIuLEAST64"\n", IB_SWITCH_TOTAL_NODE_NAME, switch_error_sum.LinkRecovers); printf("%s,LinkDowned_sum,%"PRIuLEAST64"\n", IB_SWITCH_TOTAL_NODE_NAME, switch_error_sum.LinkDowned); printf("%s,LinkDowned_sum_counter,%"PRIuLEAST64"\n", IB_SWITCH_TOTAL_NODE_NAME, switch_error_sum.LinkDowned); printf("%s,RcvErrors_sum,%"PRIuLEAST64"\n", IB_SWITCH_TOTAL_NODE_NAME, switch_error_sum.RcvErrors); printf("%s,RcvErrors_sum_counter,%"PRIuLEAST64"\n", IB_SWITCH_TOTAL_NODE_NAME, switch_error_sum.RcvErrors); printf("%s,RcvRemotePhysErrors_sum,%"PRIuLEAST64"\n", IB_SWITCH_TOTAL_NODE_NAME, switch_error_sum.RcvRemotePhysErrors); printf("%s,RcvRemotePhysErrors_sum_counter,%"PRIuLEAST64"\n", IB_SWITCH_TOTAL_NODE_NAME, switch_error_sum.RcvRemotePhysErrors); printf("%s,RcvSwitchRelayErrors_sum,%"PRIuLEAST64"\n", IB_SWITCH_TOTAL_NODE_NAME, switch_error_sum.RcvSwitchRelayErrors); printf("%s,RcvSwitchRelayErrors_sum_counter,%"PRIuLEAST64"\n", IB_SWITCH_TOTAL_NODE_NAME, switch_error_sum.RcvSwitchRelayErrors); printf("%s,XmtDiscards_sum,%"PRIuLEAST64"\n", IB_SWITCH_TOTAL_NODE_NAME, switch_error_sum.XmtDiscards); printf("%s,XmtDiscards_sum_counter,%"PRIuLEAST64"\n", IB_SWITCH_TOTAL_NODE_NAME, switch_error_sum.XmtDiscards); printf("%s,XmtConstraintErrors_sum,%"PRIuLEAST64"\n", IB_SWITCH_TOTAL_NODE_NAME, switch_error_sum.XmtConstraintErrors); printf("%s,XmtConstraintErrors_sum_counter,%"PRIuLEAST64"\n", IB_SWITCH_TOTAL_NODE_NAME, switch_error_sum.XmtConstraintErrors); printf("%s,RcvConstraintErrors_sum,%"PRIuLEAST64"\n", IB_SWITCH_TOTAL_NODE_NAME, switch_error_sum.RcvConstraintErrors); printf("%s,RcvConstraintErrors_sum_counter,%"PRIuLEAST64"\n", IB_SWITCH_TOTAL_NODE_NAME, switch_error_sum.RcvConstraintErrors); printf("%s,LinkIntegrityErrors_sum,%"PRIuLEAST64"\n", IB_SWITCH_TOTAL_NODE_NAME, switch_error_sum.LinkIntegrityErrors); printf("%s,LinkIntegrityErrors_sum_counter,%"PRIuLEAST64"\n", IB_SWITCH_TOTAL_NODE_NAME, switch_error_sum.LinkIntegrityErrors); printf("%s,ExcBufOverrunErrors_sum,%"PRIuLEAST64"\n", IB_SWITCH_TOTAL_NODE_NAME, switch_error_sum.ExcBufOverrunErrors); printf("%s,ExcBufOverrunErrors_sum_counter,%"PRIuLEAST64"\n", IB_SWITCH_TOTAL_NODE_NAME, switch_error_sum.ExcBufOverrunErrors); printf("%s,VL15Dropped_sum,%"PRIuLEAST64"\n", IB_SWITCH_TOTAL_NODE_NAME, switch_error_sum.VL15Dropped); printf("%s,VL15Dropped_sum_counter,%"PRIuLEAST64"\n", IB_SWITCH_TOTAL_NODE_NAME, switch_error_sum.VL15Dropped); } genders_open_fail: genders_handle_destroy(genders_handle); #endif free_res: mysql_free_result(res); return (rc); }