HRESULT sdk_mesh::create(ID3D11Device* device, LPCTSTR file) { HRESULT hr; sdk_mesh_.reset(new CDXUTSDKMesh); tstring path = extract_path(file); SDKMESH_CALLBACKS11 callbacks; callbacks.pCreateTextureFromFile = &dune::load_texture_cb; callbacks.pCreateVertexBuffer = nullptr; callbacks.pCreateIndexBuffer = nullptr; callbacks.pContext = reinterpret_cast<void*>(&path); V_RETURN(sdk_mesh_->Create(device, file, false, &callbacks)); V_RETURN(cb_mesh_data_vs_.create(device)); V_RETURN(cb_mesh_data_ps_.create(device)); init_bb(sdk_mesh_->GetMeshBBoxCenter(0)); for (UINT i = 0; i < sdk_mesh_->GetNumMeshes(); ++i) { update_bb(sdk_mesh_->GetMeshBBoxCenter(i) - sdk_mesh_->GetMeshBBoxExtents(i)); update_bb(sdk_mesh_->GetMeshBBoxCenter(i) + sdk_mesh_->GetMeshBBoxExtents(i)); } return S_OK; }
void composite_mesh::create(ID3D11Device* device, const tstring& file) { mesh_ptr m; vs_ = nullptr; ps_ = nullptr; load_model(device, file, m); if (meshes_.empty()) init_bb(m->bb_min()); else update_bb(m->bb_min()); update_bb(m->bb_max()); meshes_.push_back(m); }
bool Block3D::collide(Block3D* other) { Vector3f omax = other->get_bb_max(); Vector3f omin = other->get_bb_min(); if (changed) update_bb(); //cout << "us " << max << " " << min << endl; //cout << "them " << omax << " " << omin << endl;; bool colx = collide_x(&omax,&omin); bool coly = collide_y(&omax,&omin); bool colz = collide_z(&omax,&omin); //cout << "x y z " << colx << " " << coly << " " << colz << endl; if (colx && coly && colz) return true; else return false; }
Vector3f Block3D::get_bb_max() { if (changed) update_bb(); return max; }
Vector3f Block3D::get_bb_min() { if (changed) update_bb(); return min; }