ComplexObject::ComplexObject(Mesh mesh) { this->mesh = mesh; Material defaultMaterial = Material(); nullVector = Vec3Df(0, 0, 0); noHit = Hit(0, nullVector, nullVector, defaultMaterial); initBoundingBox(); }
void CalCoreBone::calculateBoundingBox(CalCoreModel * pCoreModel) { int boneId = m_pCoreSkeleton->getCoreBoneId(m_strName); bool bBoundsComputed = false; initBoundingBox(); int meshId; for(meshId=0; meshId < pCoreModel->getCoreMeshCount(); ++meshId) { CalCoreMesh * pCoreMesh = pCoreModel->getCoreMesh(meshId); int submeshId; for(submeshId=0;submeshId<pCoreMesh->getCoreSubmeshCount();submeshId++) { CalCoreSubmesh *pCoreSubmesh = pCoreMesh->getCoreSubmesh(submeshId); if(pCoreSubmesh->getSpringCount()==0) { std::vector<CalCoreSubmesh::Vertex>& vectorVertex = pCoreSubmesh->getVectorVertex(); for(size_t vertexId=0;vertexId <vectorVertex.size(); ++vertexId) { for(size_t influenceId=0;influenceId<vectorVertex[vertexId].vectorInfluence.size();++influenceId) { CalCoreSubmesh::Influence &influence = vectorVertex[vertexId].vectorInfluence[influenceId]; if(influence.boneId == boneId && influence.weight > 0.5f) { const bool updated = updateBoundingBox(vectorVertex[vertexId].position); bBoundsComputed = bBoundsComputed || updated; } } } } } } // To handle bones with no vertices assigned (do not "optimize" this code away!) if(!bBoundsComputed) { for(int planeId = 0; planeId < 6; ++planeId) { m_boundingBox.plane[planeId].setPosition(m_translation); m_boundingPosition[planeId] = m_translation; } } m_boundingBoxPrecomputed = true; }
Sphere::Sphere(Vector3d p_center, float p_radius, Shader* p_shader) : Object3d(p_shader) { setName("sphere"); setCenter(p_center); setRadius(p_radius); initBoundingBox(); }