void GeometryPlotterApp::buildGUI () { tabMenuPtr menu = std::make_shared <GUITabMenu> (3, 50.0f, 10.0f, 20.0f, 50.0f); ColorAf bc = ColorAf (0.5f, 0.0f, 0.5f, 0.3f); ColorAf bc2 = ColorAf (1.0f, 1.0f, 1.0f, 0.3f); ColorAf hc = ColorAf (0.0f, 0.0f, 0.0f, 1.0f); for (int i = 0; i < 3; i++) { menu->SetBackColor (bc, i); menu->SetHighColor (hc, i); } menu->SetBackColor (bc2, 2); sliderPtr s1 = std::make_shared <GUISlider> (); s1->SetXPos (30); s1->SetBPos(0.0f); s1->SetLength (200); s1->SetbRad (15); s1->SetHeight (50.0f); menu->add (s1, 0); m_gui.add (menu); m_gui.addResize (menu); }
void SplatTestApp::draw() { gl::clear(Color(0.0f, 0.0f, 0.0f)); gl::setMatrices(camera); if (renderDebugGraphics) { gl::enableDepth(); gl::disableAlphaBlending(); gl::color(ColorAf(0, 0, 1, 0.5f)); gl::bindStockShader(gl::ShaderDef().color()); gl::drawStrokedCube(particleSys->volumeBounds); gl::drawCoordinateFrame(0.25f, 0.05f, 0.01f); } gl::enableDepthRead(); gl::disableDepthWrite(); gl::enableAlphaBlendingPremult(); gl::enable(GL_PROGRAM_POINT_SIZE); particleSys->draw(getWindowHeight() / 100.0f); if (!isFullScreen()) { ui::Render(); } }
void GeometryPlotterApp::draw() { // clear out the window with black gl::clear( Color(0.5f, 0.5f, 0.5f) ); gl::enableDepthRead (); // Setup the camera gl::pushMatrices (); gl::setMatricesWindowPersp (getWindowWidth (), getWindowHeight ()); gl::setMatrices (m_mayaCam.getCamera ()); // Enable depth buffer gl::enableDepthRead (); gl::enableDepthWrite (); gl::enableAlphaBlending (); float size = 100; float step = 1.0; gl::color( ColorAf(0.2f, 0.2f, 0.2f, 0.5f) ); for(float i=-size;i<=size;i+=step) { gl::drawLine( Vec3f(i, 0.0f, -size), Vec3f(i, 0.0f, size) ); gl::drawLine( Vec3f(-size, 0.0f, i), Vec3f(size, 0.0f, i) ); } gl::popMatrices (); m_gui.draw (getWindowSize ()); }
void Dodecahedron::drawSonicCones( int wall ) { transformToWallCoordinateSystem(wall); glLineWidth(1.3); glEnable(GL_LINE_SMOOTH); float radius,minRadius = 10.0f, maxRadius=128.0f; int step = 13,circlePoints = 16; int length = 1000; float idx= 0.0f,idxCircle=0.0f; Vec3f v; for( int ring = 0 ; ring < length ; ring+=step ){ idx = ring/(float)length; //increasing radius radius = minRadius + idx * (maxRadius-minRadius); //fade out gl::color( ColorAf(0.6,0.7,0.8,0.3f-0.3f*idx) ); //draw a circle glBegin(GL_LINE_LOOP); for( int i = 0 ; i < circlePoints ; i++ ){ idxCircle = (float)i/circlePoints; v = Vec3f( radius * sin( 2 * 3.14 * idxCircle ) , radius * cos( 2 * 3.14 * idxCircle ) , idx * length ); glVertex3fv( v ); } glEnd(); } popWallCoordinateSystem(); }
void VirtualPad::draw(float x, float y, float w, float h) { float sizeScale = 1.0; float labelOffset = 0.0; ColorAf fontColor = ColorAf(0, 0, 0, 1); if (index == LP_SETUP) { sizeScale = 0.5; labelOffset = -h / 3; fontColor = ColorAf(1, 1, 1, 1); } gl::pushModelMatrix(); gl::translate(x, y); gl::scale(w * sizeScale, h * sizeScale, 1); prog->uniform("uColor", color.get(ColorModel::CM_RGB)); if (isButton) { circleBatch->draw(); } else { rectBatch->draw(); } gl::popModelMatrix(); if (isButton) { float fontScale = h / 4 / font.getSize(); auto opts = gl::TextureFont::DrawOptions().scale(fontScale); vec2 size = textureFont->measureString(label, opts); gl::color(fontColor); textureFont->drawString( label, vec2(x - fontScale * size.x / 2, y + fontScale * size.y / 4 + labelOffset), opts); } }
/** * Update the modl state */ void Dodecahedron::update() { radius = 300 * get( "radius" ); modelRotation = 64 * Vec3f( get( "rotationX" ) , get( "rotationY" ) , get( "rotationZ" ) ); edgesColor = ColorAf( get( "edgeColorR" ) , get( "edgeColorG" ) , get( "edgeColorB" ) ); updateVertices(); calcWallCenters(); calcWallCoordinateSystems(); }
/** * Reality check - if the center is in the middle of the wall */ void Dodecahedron::__drawWallCenter( int wall ) { Vec3f v = wallCenters[wall]; glPushMatrix(); v = wallCenters[wall]; gl::color( ColorAf(1.0,1.0,1.0) ); gl::drawCube( v , Vec3f( 3 , 3 , 3 ) ); glPopMatrix(); }
/** * Helper method for drawing vertices referenced by position in vertices array */ void Dodecahedron::drawWall( int wall ) { Vec3f v; glEnable(GL_LINE_SMOOTH); glLineWidth(4.0f); gl::color( ColorAf(1.0,1.0,1.0,0.3f) ); glBegin(GL_LINE_STRIP); for( int i = 0 ; i < VERTICES_PER_WALL ; i++ ){ v = vertices[ wallVerticeIds[wall][i] ]; glVertex3fv( v ); } glEnd(); glLineWidth(1.0f); }
/** * Reality check - drawign the wall's local coordinate system */ void Dodecahedron::__drawWallCoordinateSystem( int wall ) { Vec3f vCenter = wallCenters[wall]; Vec3f coordinateSystem[3] = wallCoordinateSystems[wall]; float radius = 10.0; //TEST //reality check - draw the axes from the base coordinate system glLineWidth(4.0f); gl::color( ColorAf(1.0,0.0,0.0,0.4f) ); gl::drawVector( vCenter , vCenter+radius*coordinateSystem[0] ); gl::color( ColorAf(0.0,1.0,0.0,0.4f) ); gl::drawVector( vCenter , vCenter+radius*coordinateSystem[1] ); gl::color( ColorAf(0.0,0.0,1.0,0.4f) ); gl::drawVector( vCenter , vCenter+radius*coordinateSystem[2] ); glLineWidth(1.0f); transformToWallCoordinateSystem(wall); // //Start drawing here... // //TEST //reality check - draw the axes in the walls in the wall's coordinate system gl::color( ColorAf(1.0,0.0,0.0,0.6f) ); gl::drawVector( Vec3f(0,0,0) , 2*radius*Vec3f::xAxis() ); gl::color( ColorAf(0.0,1.0,0.0,0.6f) ); gl::drawVector( Vec3f(0,0,0) , 2*radius*Vec3f::yAxis() ); gl::color( ColorAf(0.0,0.0,1.0,0.6f) ); gl::drawVector( Vec3f(0,0,0) , 2*radius*Vec3f::zAxis() ); //yeah, it's always more fun with a flat cube at (10,20,0) gl::color( ColorAf(1,1,1,0.3f) ); gl::drawCube( Vec3f( 10, 20 , 0 ) , Vec3f( 10, 10, 1) ); //.... // //end drawing here // popWallCoordinateSystem(); }
/** * Constructor */ Dodecahedron::Dodecahedron() { set( "edgeColorR" , 1.0f ); edgesColor = ColorAf(get("edgesColorR"),0,0); updateVertices(); }