MeshX::MeshX(const char *xFileName) { this->mesh = NULL; HRESULT hr; animCtrl = 0; CreateWindowHandle(); CreateDirect3dDevice(); allocMeshHierarchy.setDevice(pDevice); //try to load skinned mesh hr = D3DXLoadMeshHierarchyFromXA(xFileName, D3DXMESH_SYSTEMMEM, pDevice, &allocMeshHierarchy, 0, /* ignore user data */ (D3DXFRAME**)&root, &animCtrl); if (FAILED(hr)) { throw std::bad_alloc(); } skinInfo = allocMeshHierarchy.GetMeshList().front()->pSkinInfo; BuildSkinnedMesh(); boneMatrices = new D3DXMATRIX[skinInfo->GetNumBones()]; boneMatrices3x4 = HQMatrix3x4::NewArray(skinInfo->GetNumBones()); }
int main(int argc, char **argv) { #if defined (_DEBUG) || defined(DEBUG) _CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF ); //_crtBreakAlloc = 245; #endif if (argc < 3) { printf("usage: <input> [options] <output>\n"); return -1; } //parse options int flags = 0; for (int i = 2; i < argc - 1; ++i){ if (strcmp(argv[i], "-flat") == 0) flags |= FLAG_FLAT_FACES;//flat faces model else if (strcmp(argv[i], "-32bidx") == 0) flags |= FLAG_FORCE_32BIT_INDICES;//use 32 bit index data else if (!strcmp(argv[i], "-info")) flags |= FLAG_OUTPUT_ADDITIONAL_INFO;//output more info else if (!strcmp(argv[i], "-whitetex")) flags |= FLAG_FORCE_WHITE_TEXTURE;//submesh without texture will be forced to use white texture } //check if this is .x file bool isXFile = false; const char *ext = strrchr(argv[1], '.'); if (ext != NULL) { ext += 1; if (!strcmp(ext,"X") || !strcmp(ext,"x")) isXFile = true; } if (isXFile) { //create dummy window and dummy d3d device CreateWindowHandle(); CreateDirect3dDevice(); ConvertXToHQMeshFile(argv[argc - 1], argv[1], flags); CleanUpDirectX(); } else { ConvertToHQMeshFile(argv[argc - 1], argv[1], flags); } return 0; }
void * SetWindowSize(const int width, const int height) { CreateWindowHandle(width, height); // Create offscreen bitmap gPixelData = GetPixelBuffer(width, height); // open the window // Display the window on the screen ShowWindow(ghWnd, SW_SHOW); UpdateWindow(ghWnd); return gPixelData; }