void SceneGraph::update(Vec3 centerPosition, Vec3 eyePosition, Vec3 upVector, Mat4 modelViewMatrix){ float dist; //check for collisions for(int x = 1; x < numObj; x++){ for(int y = x+1; y < numObj; y++){ dist = distance(myObjs[x].BB.center, myObjs[y].BB.center); if(dist<=(float(myObjs[x].BB.width+ myObjs[y].BB.width))){ if(myObjs[x].BB.width > myObjs[y].BB.width){ //myObjs[x].BB is larger and will become the parent //but first we have to make sure the smaller obj doesn't already have a parent if(myObjs[y].parent->name=="World"){ //object has no parent myObjs[y].addParent(&myObjs[x]); }else{ //object has parent if(myObjs[y].parent->BB.width > myObjs[x].BB.width){ myObjs[x].addParent(myObjs[y].parent); }else if(myObjs[y].parent->name.c_str() != myObjs[x].name.c_str()){ myObjs[y].parent->addParent(&myObjs[x]); } } } else{ //myObjs[y].BB is larger and will become the parent //but first we have to make sure the smaller obj doesn't already have a parent if(myObjs[x].parent->name=="World"){ //object has no parent myObjs[x].addParent(&myObjs[y]); }else{ //object has parent if(myObjs[x].parent->BB.width > myObjs[y].BB.width){ myObjs[y].addParent(myObjs[x].parent); }else if(myObjs[x].parent->name.c_str() != myObjs[y].name.c_str()){ myObjs[x].parent->addParent(&myObjs[y]); } } } } } } //update parents/children updatePly(); draw(centerPosition, eyePosition, upVector, modelViewMatrix); }
void ChartWidget::resizeEvent(QResizeEvent*) { updatePly(); updatePolygon(); }
void ChartWidget::setPly(int ply) { m_ply = ply; updatePly(); repaint(); }