Note that there are some explanatory texts on larger screens.

plurals
  1. POrotating model while color updating
    primarykey
    data
    text
    <p>In OpenGL, I draw tree(composed of lines) like structure(neurons), and based on activity, i apply a color on each of the branches of the tree. Each branch portion may have a different color at an instance. I keep record of the color at an instance corresponding to the branch. </p> <p>I am able to rotate (by changing the modelview matrix) the tree. I can see the changing color (activity) on the branches when updating. </p> <p>However, i am not able to rotate the tree while the color change is happening. (the rotation is seen after the complete updating) This is also true with translating the model, not able to translate while updating. </p> <p>How should i be doing this to see them simultaneously? </p> <p>i call the updateViz function to update the colors. </p> <pre><code>def render(self): glMatrixMode(GL_MODELVIEW) glLoadIdentity() self.renderAxis() #draws 3 axes at origin for obj in self.vizObjects: glPushMatrix() glColor(obj.r, obj.g, obj.b) glLineWidth(2) glBegin(GL_LINES) glVertex3f(obj.l_coords[0],obj.l_coords[1],obj.l_coords[2]) glVertex3f(obj.l_coords[3],obj.l_coords[4],obj.l_coords[5]) glEnd() glPopMatrix() def updateViz(self,vals): inds = digitize(vals,colrMapVals) for i in range(0,len(self.vizObjects)): self.vizObjects[i].r,self.vizObjects[i].g,self.vizObjects[i].b= colorMap[inds[i]-1] def translate(self, _trans): self.makeCurrent() glMatrixMode(GL_MODELVIEW) glLoadIdentity() glTranslated(_trans[0], _trans[1], _trans[2]) glMultMatrixd(self.modelview_matrix_) self.modelview_matrix_ = glGetDoublev(GL_MODELVIEW_MATRIX) self.translate_vector_[0] = self.modelview_matrix_[3][0] self.translate_vector_[1] = self.modelview_matrix_[3][1] self.translate_vector_[2] = self.modelview_matrix_[3][2] def rotate(self, _axis, _angle): #self.modelview_matrix_ = glGetDoublev(GL_MODELVIEW_MATRIX) t = [self.modelview_matrix_[0][0] * self.center_[0] + self.modelview_matrix_[1][0] * self.center_[1] + self.modelview_matrix_[2][0] * self.center_[2] + self.modelview_matrix_[3][0], self.modelview_matrix_[0][1] * self.center_[0] + self.modelview_matrix_[1][1] * self.center_[1] + self.modelview_matrix_[2][1] * self.center_[2] + self.modelview_matrix_[3][1], self.modelview_matrix_[0][2] * self.center_[0] + self.modelview_matrix_[1][2] * self.center_[1] + self.modelview_matrix_[2][2] * self.center_[2] + self.modelview_matrix_[3][2]] self.makeCurrent() glLoadIdentity() glTranslatef(t[0], t[1], t[2]) glRotated(_angle, _axis[0], _axis[1], _axis[2]) glTranslatef(-t[0], -t[1], -t[2]) glMultMatrixd(self.modelview_matrix_) self.modelview_matrix_ = glGetDoublev(GL_MODELVIEW_MATRIX) def keyPressEvent(self, ev): if (ev.key() == QtCore.Qt.Key_Left): self.translate([-0.25, 0.0, 0.0]) self.updateGL() elif (ev.key() == QtCore.Qt.Key_Right): self.translate([0.25, 0.0, 0.0]) self.updateGL() elif (ev.key() == QtCore.Qt.Key_A): self.rotate([1.0, 0.0, 0.0],2.0) self.updateGL() elif (ev.key() == QtCore.Qt.Key_Q): self.rotate([1.0, 0.0, 0.0],-2.0) self.updateGL() </code></pre> <p>I use PyQt4 and PyGLWidget</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload