Model::Model(std::string filename, bool invert) { std::vector<float> vertice_data; aiMatrix4x4 trafo; aiIdentityMatrix4(&trafo); scene = aiImportFile(filename.c_str(), aiProcessPreset_TargetRealtime_Quality);// | aiProcess_FlipWindingOrder); if (!scene) { std::string log = "Unable to load mesh from "; log.append(filename); THROW_EXCEPTION(log); } //Load the model recursively into data loadRecursive(root, invert, vertice_data, scene, scene->mRootNode); //Get bounding box and scale it std::pair<float, glm::vec3> aabb = FindBoundingBox(vertice_data); //Apply scale root.transform = glm::scale(root.transform, glm::vec3(aabb.first, aabb.first, aabb.first)); //Apply translation root.transform = glm::translate(root.transform, aabb.second); n_vertices = vertice_data.size(); //Create the VBOs from the data. if (fmod(static_cast<float>(n_vertices), 3.0f) < 0.000001f){ vertices.reset(new GLUtils::VBO(vertice_data.data(), n_vertices*sizeof(float))); } else THROW_EXCEPTION("The number of vertices in the mesh is wrong"); }
void RegionOfInterest::DrawBoundingBoxforRegionOfInterest(cv::Mat inputFrame_) { FindBoundingBox(); cv::rectangle(inputFrame_, boundingRect, cv::Scalar(0,255,0), 1, 8, 0); //cv::imshow("bounding box", inputFrame_); }
// Erase everything void Model3D::Clear() { Positions.clear(); TxtrCoords.clear(); Normals.clear(); Colors.clear(); VtxSrcIndices.clear(); VtxSources.clear(); NormSources.clear(); InverseVSIndices.clear(); InvVSIPointers.clear(); Bones.clear(); VertIndices.clear(); Frames.clear(); SeqFrames.clear(); SeqFrmPointers.clear(); FindBoundingBox(); }
void kDOPTree::BuildNode( kDOPTree::kDOPNode* pNode ) { mDepth++; if( mDepth > mMaxDepth ) mMaxDepth = mDepth; FindBoundingBox( pNode ); // Test if we're creating a leaf or a node. if( pNode->mTriangleIndices.size() > 5 ) { mNumNodes++; Float axisMean; Axis splitAxis = SelectSplitAxis( pNode->mTriangleIndices, axisMean ); // Add two nodes. kDOPNode* leftNode = GD_NEW(kDOPNode, this, "Engine::Collision::kDOPTree"); kDOPNode* rightNode = GD_NEW(kDOPNode, this, "Engine::Collision::kDOPTree"); pNode->mChildsIndex = mNodes.size(); mNodes.push_back( leftNode ); mNodes.push_back( rightNode ); // Split triangles into two list. SplitTriangles( pNode, splitAxis, axisMean ); // No need to store this in nodes. pNode->mTriangleIndices.clear(); // Recursively call build tree. BuildNode( leftNode ); BuildNode( rightNode ); } else { // No work to do for leaves! mNumLeaves++; } mDepth--; }