bool CExporter::generateSkinBone(grp::SkinnedMeshExporter* skinnedMesh, INode* node, ISkin* skin) { Matrix3 mSkinOffset; if (!skin->GetSkinInitTM(node, mSkinOffset, true)) { setLastError("获取Skin偏移矩阵失败"); return false; } int iNumBone = skin->GetNumBones(); skinnedMesh->m_boneNames.resize(iNumBone); skinnedMesh->m_offsetMatrices.resize(iNumBone); for (int i = 0; i < iNumBone; ++i) { //mbs only INode* pBone = skin->GetBone(i); if (NULL == pBone) { setLastError("找不到skin依赖的骨骼"); return false; } if (ENUM_NODE_DUMMY == checkNodeType(pBone)) { char szError[1024]; ::StringCchPrintf(szError, sizeof(szError), "发现绑定到虚拟体[%s]的顶点", pBone->GetName()); setLastError(szError); return false; } wchar_t unicodeString[256]; mbstowcs(unicodeString, pBone->GetName(), 255); skinnedMesh->m_boneNames[i] = unicodeString; Matrix3 mBoneOffset; skin->GetBoneInitTM(pBone, mBoneOffset); mBoneOffset.Invert(); Matrix3 meshOffset = node->GetObjectTM(0); mBoneOffset = meshOffset * mBoneOffset; //mBoneOffset = mSkinOffset * mBoneOffset; grp::Matrix& mCore = skinnedMesh->m_offsetMatrices[i]; ::MatrixFromMatrix3(mCore, mBoneOffset); } return true; }
int main(int argc, char ** argv) { int c; uint8 hfi = 1; uint8 port = 0; int index; QUERY query; OutputStringMap_t *outputTypeMap = NULL; memset(&query, 0, sizeof(query)); // initialize reserved fields // default query for this application is for all node records query.InputType = InputTypeNoInput; query.OutputType = OutputTypeStlNodeRecord; // process command line arguments while (-1 != (c = getopt_long(argc,argv, "vIh:p:l:k:i:t:s:n:g:u:m:d:P:G:a:A:o:S:L:", options, &index))) { switch (c) { case '$': Usage_full(); break; case 'v': g_verbose++; if (g_verbose>1) oib_set_dbg(stderr); if (g_verbose>2) umad_debug(g_verbose-2); break; case 'I': // issue query in legacy InfiniBand format (IB) g_IB = 1; query.OutputType = OutputTypeNodeRecord; break; case 'h': // hfi to issue query from if (FSUCCESS != StringToUint8(&hfi, optarg, NULL, 0, TRUE)) { fprintf(stderr, "opasaquery: Invalid HFI Number: %s\n", optarg); Usage(); } break; case 'p': // port to issue query from if (FSUCCESS != StringToUint8(&port, optarg, NULL, 0, TRUE)) { fprintf(stderr, "opasaquery: Invalid Port Number: %s\n", optarg); Usage(); } break; case 'l': // query by lid multiInputCheck(query.InputType); query.InputType = InputTypeLid; if (FSUCCESS != StringToUint16(&query.InputValue.Lid, optarg, NULL, 0, TRUE)) { fprintf(stderr, "opasaquery: Invalid LID: %s\n", optarg); Usage(); } break; case 'k': // query by pkey multiInputCheck(query.InputType); query.InputType = InputTypePKey; if (FSUCCESS != StringToUint16(&query.InputValue.PKey, optarg, NULL, 0, TRUE)) { fprintf(stderr, "opasaquery: Invalid PKey: %s\n", optarg); Usage(); } break; case 'i': // query by vfindex multiInputCheck(query.InputType); query.InputType = InputTypeIndex; if (FSUCCESS != StringToUint16(&query.InputValue.vfIndex, optarg, NULL, 0, TRUE)) { fprintf(stderr, "opasaquery: Invalid vfIndex: %s\n", optarg); Usage(); } break; case 'S': // query by serviceId multiInputCheck(query.InputType); query.InputType = InputTypeServiceId; if (FSUCCESS != StringToUint64(&query.InputValue.ServiceId, optarg, NULL, 0, TRUE)) { fprintf(stderr, "opasaquery: Invalid ServiceId: %s\n", optarg); Usage(); } break; case 'L': // query by service level multiInputCheck(query.InputType); query.InputType = InputTypeSL; if (FSUCCESS != StringToUint8(&query.InputValue.SL, optarg, NULL, 0, TRUE) || query.InputValue.SL > 15) { fprintf(stderr, "opasaquery: Invalid SL: %s\n", optarg); Usage(); } break; case 't': // query by node type multiInputCheck(query.InputType); query.InputType = InputTypeNodeType; query.InputValue.TypeOfNode = checkNodeType(optarg); break; case 's': // query by system image guid multiInputCheck(query.InputType); query.InputType = InputTypeSystemImageGuid; if (FSUCCESS != StringToUint64(&query.InputValue.Guid, optarg, NULL, 0, TRUE)) { fprintf(stderr, "opasaquery: Invalid GUID: %s\n", optarg); Usage(); } break; case 'n': // query by node guid multiInputCheck(query.InputType); query.InputType = InputTypeNodeGuid; if (FSUCCESS != StringToUint64(&query.InputValue.Guid, optarg, NULL, 0, TRUE)) { fprintf(stderr, "opasaquery: Invalid GUID: %s\n", optarg); Usage(); } break; case 'g': // query by port guid multiInputCheck(query.InputType); query.InputType = InputTypePortGuid; if (FSUCCESS != StringToUint64(&query.InputValue.Guid, optarg, NULL, 0, TRUE)) { fprintf(stderr, "opasaquery: Invalid GUID: %s\n", optarg); Usage(); } break; case 'u': // query by gid multiInputCheck(query.InputType); query.InputType = InputTypePortGid; if (FSUCCESS != StringToGid(&query.InputValue.Gid.AsReg64s.H,&query.InputValue.Gid.AsReg64s.L, optarg, NULL, TRUE)) { fprintf(stderr, "opasaquery: Invalid GID: %s\n", optarg); Usage(); } break; case 'm': // query by multicast gid multiInputCheck(query.InputType); query.InputType = InputTypeMcGid; if (FSUCCESS != StringToGid(&query.InputValue.Gid.AsReg64s.H,&query.InputValue.Gid.AsReg64s.L, optarg, NULL, TRUE)) { fprintf(stderr, "opasaquery: Invalid GID: %s\n", optarg); Usage(); } break; case 'd': // query by node description multiInputCheck(query.InputType); query.InputType = InputTypeNodeDesc; query.InputValue.NodeDesc.NameLength = MIN(strlen(optarg), NODE_DESCRIPTION_ARRAY_SIZE); strncpy((char*)query.InputValue.NodeDesc.Name, optarg, NODE_DESCRIPTION_ARRAY_SIZE); break; case 'P': // query by source:dest port guids { char *p; multiInputCheck(query.InputType); query.InputType = InputTypePortGuidPair; if (FSUCCESS != StringToUint64(&query.InputValue.PortGuidPair.SourcePortGuid, optarg, &p, 0, TRUE) || ! p || *p == '\0') { fprintf(stderr, "opasaquery: Invalid GUID Pair: %s\n", optarg); Usage(); } if (FSUCCESS != StringToUint64(&query.InputValue.PortGuidPair.DestPortGuid, p, NULL, 0, TRUE)) { fprintf(stderr, "opasaquery: Invalid GUID Pair: %s\n", optarg); Usage(); } } break; case 'G': // query by source:dest port gids { char *p; multiInputCheck(query.InputType); query.InputType = InputTypeGidPair; if (FSUCCESS != StringToGid(&query.InputValue.GidPair.SourceGid.AsReg64s.H,&query.InputValue.GidPair.SourceGid.AsReg64s.L, optarg, &p, TRUE) || ! p || *p == '\0') { fprintf(stderr, "opasaquery: Invalid GID Pair: %s\n", optarg); Usage(); } if (FSUCCESS != StringToGid(&query.InputValue.GidPair.DestGid.AsReg64s.H,&query.InputValue.GidPair.DestGid.AsReg64s.L, p, NULL, TRUE)) { fprintf(stderr, "opasaquery: Invalid GID Pair: %s\n", optarg); Usage(); } } break; case 'a': // multipath query by src1:src2:...;dest1:dest2:... port guids { char *p =optarg; int i = 0; errno = 0; multiInputCheck(query.InputType); query.InputType = InputTypePortGuidList; do { if (FSUCCESS != StringToUint64(&query.InputValue.PortGuidList.GuidList[i], p, &p, 0, TRUE)) { fprintf(stderr, "opasaquery: Invalid GUID List: %s\n", optarg); Usage(); } i++; query.InputValue.PortGuidList.SourceGuidCount++; } while (p && *p != '\0' && *p != ';'); if (p && *p != '\0') { p++; // skip the semi-colon. do { if (FSUCCESS != StringToUint64(&query.InputValue.PortGuidList.GuidList[i], p, &p, 0, TRUE)) { fprintf(stderr, "opasaquery: Invalid GUID List: %s\n", optarg); Usage(); } i++; query.InputValue.PortGuidList.DestGuidCount++; } while (p && *p != '\0'); } else { Usage(); } } break; case 'A': // multipath query by src1:src2:...;dest1:dest2:... gids { char *p=optarg; int i = 0; errno = 0; multiInputCheck(query.InputType); query.InputType = InputTypeGidList; do { if (FSUCCESS != StringToGid(&query.InputValue.GidList.GidList[i].AsReg64s.H,&query.InputValue.GidList.GidList[i].AsReg64s.L, p, &p, TRUE)) { fprintf(stderr, "opasaquery: Invalid GID List: %s\n", optarg); Usage(); } i++; query.InputValue.GidList.SourceGidCount++; } while (p && *p != '\0' && *p != ';'); if (p && *p != '\0') { p++; // skip the semi-colon do { if (FSUCCESS != StringToGid(&query.InputValue.GidList.GidList[i].AsReg64s.H,&query.InputValue.GidList.GidList[i].AsReg64s.L, p, &p, TRUE)) { fprintf(stderr, "opasaquery: Invalid GID List: %s\n", optarg); Usage(); } i++; query.InputValue.GidList.DestGidCount++; } while (p && *p != '\0'); } else { Usage(); } } break; case 'o': // select output record desired outputTypeMap = GetOutputTypeMap(optarg); break; default: fprintf(stderr, "opasaquery: Invalid option -%c\n", c); Usage(); break; } } /* end while */ if (optind < argc) { Usage(); } if (NULL != outputTypeMap) query.OutputType = GetOutputType(outputTypeMap); PrintDestInitFile(&g_dest, stdout); if (g_verbose) PrintDestInitFile(&g_dbgDest, stdout); else PrintDestInitNone(&g_dbgDest); if(oib_open_port_by_num(&sa_oib_session,hfi,port) != 0) { fprintf(stderr, "opasaquery: Could not open oib session.\n"); return FERROR; } // perform the query and display output do_query(sa_oib_session, &query); oib_close_port(sa_oib_session); if (g_exitstatus == 2) Usage(); return g_exitstatus; }
bool WRL2LINESET::AddChildNode( WRL2NODE* aNode ) { if( NULL == aNode ) { #ifdef DEBUG_VRML2 do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [BUG] NULL passed for aNode"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); #endif return false; } WRL2NODES type = aNode->GetNodeType(); if( !checkNodeType( type ) ) { #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [INFO] bad file format; unexpected child node '"; ostr << aNode->GetNodeTypeName( type ) << "'"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); #endif return false; } if( WRL2_COLOR == type ) { if( NULL != color ) { #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [INFO] bad file format; multiple color nodes"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); #endif return false; } color = aNode; return WRL2NODE::AddChildNode( aNode ); } if( WRL2_COORDINATE == type ) { if( NULL != coord ) { #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [INFO] bad file format; multiple coordinate nodes"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); #endif return false; } coord = aNode; return WRL2NODE::AddChildNode( aNode ); } return WRL2NODE::AddChildNode( aNode ); }
bool WRL2SHAPE::AddRefNode( WRL2NODE* aNode ) { if( NULL == aNode ) { #ifdef DEBUG_VRML2 do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [BUG] NULL passed for aNode"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); #endif return false; } WRL2NODES type = aNode->GetNodeType(); if( !checkNodeType( type ) ) { #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [INFO] bad file format; unexpected child node '"; ostr << aNode->GetNodeTypeName( type ) << "'"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); #endif return false; } if( WRL2_APPEARANCE == type ) { if( NULL != appearance ) { #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [INFO] bad file format; multiple appearance nodes"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); #endif return false; } appearance = aNode; return WRL2NODE::AddRefNode( aNode ); } if( NULL != geometry ) { #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [INFO] bad file format; multiple geometry nodes"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); #endif return false; } geometry = aNode; return WRL2NODE::AddRefNode( aNode ); }