bool CMeshVertex::Stretch(const double *p, const double* shift, void* data) { // stretch the vertex at "p" by a vector "shift" Point vp(p); Point vt = vertex(); if(vp == vt) { Point vshift(shift); Point new_vertex = vp + vshift; CMesh* mesh = (CMesh*)Owner(); if(mesh)mesh->ChangeVertex(this, new_vertex); // stretch all the edges nearest control points { std::set<CMeshEdge*>::iterator It; for(It = m_edges.begin(); It != m_edges.end(); It++) { CMeshEdge* edge = *It; CMeshPosition& c = edge->GetControlPointNearVertex(this); c.set_vertex(c.vertex() + vshift); } } // stretch the faces centre points { Point partial_vshift = vshift * 0.5; std::set<CMeshFace*>::iterator It; for(It = m_faces.begin(); It != m_faces.end(); It++) { CMeshFace* face = *It; face->m_centre.set_vertex(face->m_centre.vertex() + partial_vshift); } } return false; } for(std::set<CMeshEdge*>::iterator It = m_edges.begin(); It != m_edges.end(); It++) { CMeshEdge* edge = *It; CMeshPosition& p = edge->GetControlPointNearVertex(this); vt = p.vertex(); if(vp == vt) { Point new_vertex = vp + Point(shift); p.set_vertex(new_vertex); //edge->KillGLLists(); //edge->InvalidateBothFacesDisplayLists(); Point dir = new_vertex - vertex(); Point side_vector = dir ^ m_norm; m_norm = (side_vector ^ dir).norm(); NormalizeAllEdgeDirections(); return false; } } return false; }
void *thread_2(void *ptr) { // const struct aiScene* ai_scene2 = aiImportFile("../../unitTesting/cube.3ds",aiProcessPreset_TargetRealtime_Quality); const struct aiScene* ai_scene2 = aiImportFile(OBJECT_TO_DISPLAY,aiProcessPreset_TargetRealtime_Quality); if (global_pointer) { // global_pointer->addObject(ai_scene2, "cube2"); } int64_t time_start = ts_now(); while(1) { aiVector3D vshift( 10.0* sin( ((double) (ts_now() - time_start)) / 1000000.0 ), 0.0, 0.0 ); aiMatrix4x4 matr; aiMatrix4x4::Translation(vshift, matr); ai_scene2->mRootNode->mTransformation = matr; } return NULL; }