void MlUVView::clientDraw() { if(m_texId > -1) { glPushMatrix(); glScalef(32.f, 32.f, 1.f); glTranslatef(0.f, 0.f, -10.f); getDrawer()->texture(m_texId); glPopMatrix(); } if(!FeatherLibrary) return; MlFeather *f; for(f = FeatherLibrary->firstFeatherExample(); FeatherLibrary->hasFeatherExample(); f = FeatherLibrary->nextFeatherExample()) { if(!f) continue; drawFeather(f); } f = FeatherLibrary->selectedFeatherExample(); if(!f) return; getDrawer()->boundingRectangle(f->getBoundingRectangle()); if(interactMode() == ToolContext::MoveVertexInUV) { drawControlVectors(f); if(m_selectedVert) { Vector3F pv(m_selectVertWP); getDrawer()->cube(pv, 0.1f); } } }
//! [7] void Base3DView::paintGL() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT ); glLoadIdentity(); float m[16]; getCamera()->getMatrix(m); glMultMatrixf(m); getDrawer()->m_markerProfile.apply(); getDrawer()->coordsys(20.f); getDrawer()->setAlignDir(getCamera()->eyeDirection()); clientDraw(); if(m_isFocused) { Vector3F corners[4]; getCamera()->frameCorners(corners[0], corners[1], corners[2], corners[3]); glColor3f(0.f, 0.f, 1.f); glBegin(GL_LINE_LOOP); glVertex3f(corners[0].x, corners[0].y, corners[0].z); glVertex3f(corners[1].x, corners[1].y, corners[1].z); glVertex3f(corners[2].x, corners[2].y, corners[2].z); glVertex3f(corners[3].x, corners[3].y, corners[3].z); glEnd(); } glFlush(); }
void Base3DView::drawIntersection() const { IntersectionContext * ctx = getIntersectionContext(); if(!ctx->m_success) return; getDrawer()->circleAt(ctx->m_hitP, ctx->m_hitN); getDrawer()->boundingBox(ctx->m_bbox); getDrawer()->arrow(ctx->m_hitP, ctx->m_hitP + ctx->m_hitN); }
void ParticleSystemCore::adjustVolume(Volume & volume) { //The adjusted volume is dependent on the Particle System as well as the //Particle Drawer Inherited::adjustVolume(volume); if(getDrawer() != NULL && getSystem() != NULL) { getDrawer()->adjustVolume(getSystem(), volume); } }
void Base3DView::showBrush() const { getDrawer()->colorAsReference(); getDrawer()->circleAt(brush()->getSpace(), brush()->getRadius()); if(m_brush->dropoff() > 0.f) getDrawer()->circleAt(brush()->getSpace(), brush()->getRadius() * (1.f - m_brush->dropoff())); if(brush()->length() > 10e-3) getDrawer()->arrow(brush()->heelPosition(), brush()->toePosition()); }
void GLWidget::clientDraw() { //_subdiv->draw(); getDrawer()->edge(_model); drawBezier(); }
void GLWidget::drawMesh() { CudaLinearBvh * bvh = m_mesh->bvh(); Aabb ab = bvh->bound(); if(ab.low.x < -1e8 || ab.low.x > 1e8) std::cout<<" invalid big box "<<aabb_str(ab); #ifdef BVHSOLVER_DBG_DRAW unsigned numInternal = bvh->numInternalNodes(); debugDraw(*m_rootNodeInd, numInternal); #else GeoDrawer * dr = getDrawer(); BoundingBox bb; bb.setMin(ab.low.x, ab.low.y, ab.low.z); bb.setMax(ab.high.x, ab.high.y, ab.high.z); dr->boundingBox(bb); #endif #ifdef BVHSOLVER_DRAW_MESH glColor3f(0.f, 0.3f, 0.5f); //internalTimer()->stop(); glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(3, GL_FLOAT, 0, (GLfloat*)m_mesh->vertices()); glDrawElements(GL_TRIANGLES, m_mesh->numTriangleFaceVertices(), GL_UNSIGNED_INT, m_mesh->triangleIndices()); glDisableClientState(GL_VERTEX_ARRAY); #endif }
void scigraphics::plot::replotFloatRectangles() { if ( getDrawer() == NULL ) throw std::runtime_error( "Drawer is not initialized" ); drawFloatRectangles(); flush(); }
void MlUVView::drawActiveBound() { if(!FeatherLibrary) return; MlFeather * f = FeatherLibrary->selectedFeatherExample(); if(!f) return; getDrawer()->boundingRectangle(f->getBoundingRectangle()); }
void MlUVView::loadImageBackground(const std::string & name) { if(!MlFeather::ColorTextureFile.open(name)) return; MlFeather::ColorTextureFile.verbose(); makeCurrent(); m_texId = getDrawer()->loadTexture(m_texId, &MlFeather::ColorTextureFile); doneCurrent(); update(); emit shapeChanged(); }
void ParticleSystemCore::fill(DrawableStatsAttachment *pStat) { if(getDrawer() == NULL) { FINFO(("ParticleSystemCore::fill(DrawableStatsAttachment *): " "No Drawer Attached.\n")); return; } if(getSystem() == NULL) { FINFO(("ParticleSystemCore::fill(DrawableStatsAttachment *): " "No System Attached.\n")); return; } getDrawer()->fill(pStat, getSystem(), *getMFSort()); }
void MlUVView::drawVaneVectors(BaseVane * vane) { GeoDrawer * dr = getDrawer(); for(unsigned j = 0; j <= vane->gridU(); j++) { for(unsigned k = 0; k < vane->gridV(); k++) { Vector3F cv0 = *vane->railCV(j, k) * 32.f; Vector3F cv1 = *vane->railCV(j, k+1) * 32.f; dr->arrow(cv0, cv1); } } }
void ParticleSystemCore::drawPrimitives (DrawEnv *pEnv) { //If I have a Drawer tell it to draw the particles if(getDrawer() != NULL && getSystem() != NULL) { checkAndInitializeSort(); sortParticles(pEnv); getDrawer()->draw(pEnv, getSystem(), *getMFSort()); } else { if(getDrawer() == NULL) { FWARNING(("ParticleSystemCore::draw: ParticleSystemDrawer is Null.")); } if(getSystem() == NULL) { FWARNING(("ParticleSystemCore::draw: ParticleSystem is Null.")); } } }
void GLWidget::clientDraw() { if(m_thread->numLoops() < WorldThread::NumSubsteps) { emit updatePhysics(); return; } std::stringstream sst; sst.str(""); sst<<"fps: "<<frameRate(); hudText(sst.str(), 1); #if DRGDRW if(m_isPhysicsRunning) m_interface->draw(m_world, getDrawer()); #else if(m_isPhysicsRunning) { emit updatePhysics(); m_interface->draw(m_world, getDrawer()); m_world->dbgDraw(); } #endif //else m_interface->drawFaulty(m_world, getDrawer()); }
void Base3DView::initializeGL() { #ifdef WIN32 if(gExtensionInit()) qDebug()<<"GL Extensions checked."; #endif qglClearColor(m_backgroundColor.dark()); glEnable(GL_DEPTH_TEST); glEnable(GL_COLOR_MATERIAL); glEnable(GL_TEXTURE_2D); glShadeModel(GL_SMOOTH); glHint( GL_LINE_SMOOTH_HINT, GL_NICEST ); glHint( GL_POLYGON_SMOOTH_HINT, GL_NICEST ); // glEnable(GL_MULTISAMPLE); glDepthFunc(GL_LEQUAL); getDrawer()->initializeProfile(); m_hud->reset(); clientInit(); }
void MlUVView::drawControlVectors(MlFeather * f) { Vector3F baseP(f->baseUV()); GeoDrawer * dr = getDrawer(); glPushMatrix(); Matrix44F s; s.setTranslation(baseP); float * quill = f->getQuilly(); Vector3F b, a; Vector2F *d; for(short i=0; i <= f->numSegment(); i++) { dr->useSpace(s); a.setZero(); d = f->uvDisplaceAt(i, 0); for(short j = 0; j < 3; j++) { b = d[j]; dr->arrow(a, a + b); a += b; } a.setZero(); d = f->uvDisplaceAt(i, 1); for(short j = 0; j < 3; j++) { b = d[j]; dr->arrow(a, a + b); a += b; } a.setZero(); b.set(0.f, quill[i], 0.f); if(i<f->numSegment()) dr->arrow(a, b); s.setTranslation(b); } glPopMatrix(); }
void scigraphics::plot::replot() { if ( getDrawer() == NULL ) throw std::runtime_error( "Drawer is not initialized" ); prepareForPainting(); clearPlotArea(); drawGraphicsUnderGrid(); drawGrid(); drawGraphicsOverGrid(); drawSelections(); clearBorders(); drawAxis(); drawAxisTicks(); drawAxisLabels(); drawAxisTitles(); drawFloatRectangles(); drawZoomRectangle(); flush(); }
void MlUVView::drawBindVectors(MlFeather * f) { GeoDrawer * dr = getDrawer(); const Vector3F baseP(f->baseUV()); glPushMatrix(); Matrix44F s; s.setTranslation(baseP); float * quill = f->getQuilly(); Vector3F b; for(short i=0; i < f->numSegment(); i++) { dr->useSpace(s); for(short j=0; j < f->numBind(i); j++) { DeformableFeather::BindCoord *bind = f->getBind(i, j); dr->arrow(Vector3F(0.f, 0.f, 0.f), bind->_objP * 32.f); } b.set(0.f, quill[i], 0.f); s.setTranslation(b); } glPopMatrix(); }
void GLWidget::clientDraw() { updatePerspectiveView(); getDrawer()->frustum(perspectiveView()->frustum() ); m_scene->draw(getDrawer() ); }
void GLWidget::clientInit() { CudaDynamicWorld::DbgDrawer = new WorldDbgDraw(getDrawer()); m_world->initOnDevice(); startPhysics(); }
GLWidget::GLWidget(QWidget *parent) : Base3DView(parent) { m_scene = new SceneContainer(getDrawer() ); }
void GLWidget::debugDraw(unsigned rootInd, unsigned numInternal) { #ifdef BVHSOLVER_DBG_DRAW if(!m_solver->isValid()) return; GeoDrawer * dr = getDrawer(); // qDebug()<<" root at "<< (*m_rootNodeInd & (~0x80000000)); Aabb ab; BoundingBox bb; #ifdef BVHSOLVER_DBG_DRAW_BOX Aabb * internalBoxes = (Aabb *)m_displayInternalAabbs->data(); Aabb * leafBoxes = (Aabb *)m_displayLeafAabbs->data(); int * levels = (int *)m_displayInternalDistance->data(); KeyValuePair * leafHash = (KeyValuePair *)m_displayLeafHash->data(); int2 * internalNodeChildIndices = (int2 *)m_internalChildIndices->data(); // std::cout<<" "<<numInternal/2<<" "<<byte_to_binary(leafHash[numInternal/2].key)<<" "<<leafHash[numInternal/2].value<<"\n"; int stack[128]; stack[0] = rootInd; int stackSize = 1; int maxStack = 1; int touchedLeaf = 0; int touchedInternal = 0; while(stackSize > 0) { int internalOrLeafNodeIndex = stack[ stackSize - 1 ]; stackSize--; int isLeaf = isLeafNode(internalOrLeafNodeIndex); //Internal node if false uint bvhNodeIndex = getIndexWithInternalNodeMarkerRemoved(internalOrLeafNodeIndex); int bvhRigidIndex = (isLeaf) ? leafHash[bvhNodeIndex].value : -1; Aabb bvhNodeAabb = (isLeaf) ? leafBoxes[bvhRigidIndex] : internalBoxes[bvhNodeIndex]; { if(isLeaf) { #ifdef BVHSOLVER_DBG_DRAW_LEAFBOX glColor3f(.5, 0., 0.); ab = bvhNodeAabb; bb.setMin(ab.low.x, ab.low.y, ab.low.z); bb.setMax(ab.high.x, ab.high.y, ab.high.z); dr->boundingBox(bb); #endif touchedLeaf++; } else { #ifdef BVHSOLVER_DBG_DRAW_INTERNALBOX_TO_LEVEL glColor3f(.5, .65, 0.); if(levels[bvhNodeIndex] > m_displayLevel) continue; ab = bvhNodeAabb; bb.setMin(ab.low.x, ab.low.y, ab.low.z); bb.setMax(ab.high.x, ab.high.y, ab.high.z); dr->boundingBox(bb); #endif touchedInternal++; if(stackSize + 2 > 128) { //Error } else { stack[ stackSize ] = internalNodeChildIndices[bvhNodeIndex].x; stackSize++; stack[ stackSize ] = internalNodeChildIndices[bvhNodeIndex].y; stackSize++; if(stackSize > maxStack) maxStack = stackSize; } } } } //qDebug()<<"max stack "<<maxStack<<" touch leaf "<<touchedLeaf<<" touchedInternal "<<touchedInternal; #endif #ifdef BVHSOLVER_DBG_DRAW_LEAFHASH glBegin(GL_LINES); int nzero = 0; for(unsigned i=0; i < numInternal; i++) { float red = (float)i/(float)numInternal; if(leafHash[i].value > numInternal) { qDebug()<<"invalid hash value "<<leafHash[i].value; nzero++; continue; } glColor3f(red, 1.f - red, 0.f); Aabb a0 = leafBoxes[leafHash[i].value]; glVertex3f(a0.low.x * 0.5f + a0.high.x * 0.5f, a0.low.y * 0.5f + a0.high.y * 0.5f + 0.2f, a0.low.z * 0.5f + a0.high.z * 0.5f); Aabb a1 = leafBoxes[leafHash[i+1].value]; glVertex3f(a1.low.x * 0.5f + a1.high.x * 0.5f, a1.low.y * 0.5f + a1.high.y * 0.5f + 0.2f, a1.low.z * 0.5f + a1.high.z * 0.5f); } glEnd(); if(nzero > 0) qDebug()<<"n zero code "<<nzero; #endif #endif #ifdef BVHSOLVER_DBG_DRAW_RAY RayInfo * rays = m_ray->getRays(); const unsigned nr = m_ray->numRays(); glColor3f(0.f, 0.5f, 0.2f); glBegin(GL_LINES); for(unsigned i=0; i < nr; i++) { RayInfo & r = rays[i]; glVertex3f(r.origin.x, r.origin.y, r.origin.z); glVertex3f(r.destiny.x, r.destiny.y, r.destiny.z); Vector3F a(r.destiny.x - r.origin.x, r.destiny.y - r.origin.y, r.destiny.z - r.origin.z); // qDebug()<<" "<<a.length(); } glEnd(); #endif }
GLWidget::GLWidget(QWidget *parent) : Base3DView(parent) { m_mesh = new SimpleMesh; m_ray = new RayTest; m_particles = new CudaParticleSystem; m_particles->createParticles(10 * 20 * 10); int i, j, k; Vector3F * p = (Vector3F *)m_particles->position(); for(k=0; k < 10; k++) for(j=0; j < 20; j++) for(i=0; i < 10; i++) { p->x = 2.5f * i; p->y = 2.5f * j + 100.f; p->z = 2.5f * k; p++; } Vector3F * v = (Vector3F *)m_particles->velocity(); for(i=0; i < 2000; i++) v[i].set(0.f, 10.f, 10.f); Vector3F * f = (Vector3F *)m_particles->force(); for(i=0; i < 2000; i++) f[i].setZero(); m_solver = new BvhSolver; m_displayLevel = 3; qDebug()<<"num vertices "<<m_mesh->numVertices(); qDebug()<<"num triangles "<<m_mesh->numTriangles(); qDebug()<<"num ray tests "<<(IRAYDIM * IRAYDIM); m_tetra = new CudaTetrahedronSystem; m_tetra->create(2200, 1.f, 1.f); float * hv = &m_tetra->hostV()[0]; const unsigned grdx = 43; for(j=0; j < 32; j++) { for(i=0; i<grdx; i++) { Vector3F base(2.f * i, 2.f * j, 0.5f * i); Vector3F right = base + Vector3F(1.75f, 0.f, 0.f); Vector3F front = base + Vector3F(0.f, 0.f, 1.75f); Vector3F top = base + Vector3F(0.f, 1.75f, 0.f); m_tetra->addPoint(&base.x); hv[0] = 30.f * (((float)(rand() % 199))/199.f - .5f); hv[1] = 30.f * (((float)(rand() % 199))/199.f - .5f); hv[2] = 33.f * (((float)(rand() % 199))/199.f - .5f); hv+=3; m_tetra->addPoint(&right.x); hv[0] = 30.f * (((float)(rand() % 199))/199.f - .5f); hv[1] = 38.f * (((float)(rand() % 199))/199.f - .5f); hv[2] = 35.f * (((float)(rand() % 199))/199.f - .5f); hv+=3; m_tetra->addPoint(&top.x); hv[0] = 30.f * (((float)(rand() % 199))/199.f - .5f); hv[1] = 38.f * (((float)(rand() % 199))/199.f - .5f); hv[2] = 35.f * (((float)(rand() % 199))/199.f - .5f); hv+=3; m_tetra->addPoint(&front.x); hv[0] = 30.f * (((float)(rand() % 199))/199.f - .5f); hv[1] = 38.f * (((float)(rand() % 199))/199.f - .5f); hv[2] = 35.f * (((float)(rand() % 199))/199.f - .5f); hv+=3; unsigned b = (j * grdx + i) * 4; m_tetra->addTetrahedron(b, b+1, b+2, b+3); m_tetra->addTriangle(b, b+2, b+1); m_tetra->addTriangle(b, b+1, b+3); m_tetra->addTriangle(b, b+3, b+2); m_tetra->addTriangle(b+1, b+2, b+3); // 2 // | \ // | \ // 0 - 1 // / // 3 } } /*for(j=0; j < 32; j++) { for(i=0; i<32; i++) { float * v = &m_tetra->hostV()[(j*32 + i)*3]; std::cout<<" "<<v[0]<<" "<<v[1]<<" "<<v[2]<<"\n"; } }*/ qDebug()<<"tetra n tet "<<m_tetra->numTetradedrons(); qDebug()<<"tetra n p "<<m_tetra->numPoints(); qDebug()<<"tetra n tri "<<m_tetra->numTriangles(); m_drawBvh = new DrawBvh; m_drawBvh->setDrawer(getDrawer()); m_drawBvh->setBvh(m_tetra); m_broadphase = new CudaBroadphase; m_broadphase->addBvh(m_tetra); m_drawBvh->setBroadphase(m_broadphase); }
void GLWidget::clientInit() { AdeniumWorld::DbgDrawer = new WorldDbgDraw(getDrawer()); m_world->initOnDevice(); }
GLWidget::GLWidget(QWidget *parent) : Base3DView(parent) { m_dbgDraw = new DrawNp; m_dbgDraw->setDrawer(getDrawer()); m_solver = new ContactThread; }
void MlUVView::drawFeather(MlFeather * f) { GeoDrawer * dr = getDrawer(); const unsigned nu = f->uvVane(0)->gridU() * 3; const float du = 1.f / nu; glPushMatrix(); glScalef(32.f, 32.f, 32.f); for(unsigned i=0; i <= nu; i++) { f->uvVane(0)->setU(du * i); dr->smoothCurve(*f->uvVane(0)->profile(), 2); f->uvVane(1)->setU(du * i); dr->smoothCurve(*f->uvVane(1)->profile(), 2); } glPopMatrix(); return; /* Vector3F baseP(f->baseUV()); glPushMatrix(); Matrix44F s; s.setTranslation(baseP); float * quill = f->getQuilly(); Vector3F a, b; const unsigned ncv = f->numSegment() + 1; BezierCurve quillC; quillC.createVertices(ncv); quillC.m_cvs[0] = s.transform(b); for(int i = 0; i < f->numSegment(); i++) { b.set(0.f, quill[i], 0.f); quillC.m_cvs[i + 1] = s.transform(b); s.translate(b); } quillC.computeKnots(); dr->linearCurve(quillC); dr->smoothCurve(quillC, 2); BezierCurve eRC, eLC, fRC, fLC, gRC, gLC; eRC.createVertices(ncv); eLC.createVertices(ncv); fRC.createVertices(ncv); fLC.createVertices(ncv); gRC.createVertices(ncv); gLC.createVertices(ncv); s.setTranslation(baseP); Vector2F pv; for(int i = 0; i <= f->numSegment(); i++) { b.set(0.f, quill[i], 0.f); Vector2F * vanes = f->getUvDisplaceAt(i, 0); pv = vanes[0]; eRC.m_cvs[i] = s.transform(Vector3F(pv)); pv += vanes[1]; fRC.m_cvs[i] = s.transform(Vector3F(pv)); pv += vanes[2]; gRC.m_cvs[i] = s.transform(Vector3F(pv)); vanes = f->getUvDisplaceAt(i, 1); pv = vanes[0]; eLC.m_cvs[i] = s.transform(Vector3F(pv)); pv += vanes[1]; fLC.m_cvs[i] = s.transform(Vector3F(pv)); pv += vanes[2]; gLC.m_cvs[i] = s.transform(Vector3F(pv)); s.translate(b); } eRC.computeKnots(); fRC.computeKnots(); gRC.computeKnots(); eLC.computeKnots(); fLC.computeKnots(); gLC.computeKnots(); dr->smoothCurve(gRC, 4); dr->smoothCurve(gLC, 4); const float delta = 1.f /(f->numSegment() * 2.f); for(int i=0; i <= f->numSegment() * 2; i++) { float t = delta * i; BezierCurve vaneRC; vaneRC.createVertices(4); vaneRC.m_cvs[0] = quillC.interpolate(t); vaneRC.m_cvs[1] = eRC.interpolate(t); vaneRC.m_cvs[2] = fRC.interpolate(t); vaneRC.m_cvs[3] = gRC.interpolate(t); vaneRC.computeKnots(); dr->smoothCurve(vaneRC, 4); vaneRC.m_cvs[0] = quillC.interpolate(t); vaneRC.m_cvs[1] = eLC.interpolate(t); vaneRC.m_cvs[2] = fLC.interpolate(t); vaneRC.m_cvs[3] = gLC.interpolate(t); vaneRC.computeKnots(); dr->smoothCurve(vaneRC, 4); } glPopMatrix();*/ }