MCPcopy Create free account
hub / github.com/OctoMap/octomap / drawCubes

Method drawCubes

octovis/src/OcTreeDrawer.cpp:752–838  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

750 }
751
752 void OcTreeDrawer::drawCubes(GLfloat** cubeArray, unsigned int cubeArraySize,
753 GLfloat* cubeColorArray) const {
754 if (cubeArraySize == 0 || cubeArray == NULL){
755 std::cerr << "Warning: GLfloat array to draw cubes appears to be empty, nothing drawn.\n";
756 return;
757 }
758
759 // save current color
760 GLfloat* curcol = new GLfloat[4];
761 glGetFloatv(GL_CURRENT_COLOR, curcol);
762
763 // enable color pointer when heightColorMode is enabled:
764
765 if ((m_colorMode == CM_COLOR_HEIGHT || m_colorMode == CM_GRAY_HEIGHT) && (cubeColorArray != NULL)){
766 glEnableClientState(GL_COLOR_ARRAY);
767 glColorPointer(4, GL_FLOAT, 0, cubeColorArray);
768 }
769
770 // top surfaces:
771 glNormal3f(0.0f, 1.0f, 0.0f);
772 glVertexPointer(3, GL_FLOAT, 0, cubeArray[0]);
773 glDrawArrays(GL_QUADS, 0, cubeArraySize / 3);
774 // bottom surfaces:
775 glNormal3f(0.0f, -1.0f, 0.0f);
776 glVertexPointer(3, GL_FLOAT, 0, cubeArray[1]);
777 glDrawArrays(GL_QUADS, 0, cubeArraySize / 3);
778 // right surfaces:
779 glNormal3f(1.0f, 0.0f, 0.0f);
780 glVertexPointer(3, GL_FLOAT, 0, cubeArray[2]);
781 glDrawArrays(GL_QUADS, 0, cubeArraySize / 3);
782 // left surfaces:
783 glNormal3f(-1.0f, 0.0f, 0.0f);
784 glVertexPointer(3, GL_FLOAT, 0, cubeArray[3]);
785 glDrawArrays(GL_QUADS, 0, cubeArraySize / 3);
786 // back surfaces:
787 glNormal3f(0.0f, 0.0f, -1.0f);
788 glVertexPointer(3, GL_FLOAT, 0, cubeArray[4]);
789 glDrawArrays(GL_QUADS, 0, cubeArraySize / 3);
790 // front surfaces:
791 glNormal3f(0.0f, 0.0f, 1.0f);
792 glVertexPointer(3, GL_FLOAT, 0, cubeArray[5]);
793 glDrawArrays(GL_QUADS, 0, cubeArraySize / 3);
794
795 if ((m_colorMode == CM_COLOR_HEIGHT || m_colorMode == CM_GRAY_HEIGHT)
796 && (cubeColorArray != NULL)){
797 glDisableClientState(GL_COLOR_ARRAY);
798 }
799
800 // draw bounding linies of cubes in printout:
801 if (m_colorMode == CM_PRINTOUT){
802 glDisable(GL_LIGHTING);
803 glHint (GL_LINE_SMOOTH_HINT, GL_NICEST);
804 glEnable (GL_LINE_SMOOTH);
805 glPolygonMode (GL_FRONT_AND_BACK, GL_LINE); // Draw Polygons only as Wireframes
806 glLineWidth(2.0f);
807 glColor3f(0.0f, 0.0f, 0.0f);
808 glCullFace(GL_FRONT_AND_BACK); // Don't draw any Polygons faces
809 //glDepthFunc (GL_LEQUAL);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected