| 106 | } |
| 107 | |
| 108 | void ArcballTestApp::draw() |
| 109 | { |
| 110 | CameraPersp &cam = ( mUsingCameraUi ) ? mDebugCam : mCam; |
| 111 | gl::clear( Color( 0, 0.0f, 0.15f ) ); |
| 112 | gl::setMatrices( cam ); |
| 113 | |
| 114 | // draw the earth |
| 115 | gl::enableDepthRead(); |
| 116 | gl::enableDepthWrite(); |
| 117 | gl::translate( mEarthSphere.getCenter() ); |
| 118 | gl::rotate( mArcball.getQuat() ); |
| 119 | mEarthTex->bind(); |
| 120 | mEarth->draw(); |
| 121 | |
| 122 | // draw constraint axis |
| 123 | if( mArcball.isUsingConstraint() ) { |
| 124 | gl::setMatrices( cam ); |
| 125 | gl::color( 1, 1, 0 ); |
| 126 | gl::translate( mEarthSphere.getCenter() ); |
| 127 | gl::rotate( glm::rotation( vec3( 0, 1, 0 ), mArcball.getConstraintAxis() ) ); |
| 128 | mConstraintAxis->draw(); |
| 129 | } |
| 130 | |
| 131 | gl::disableDepthRead(); |
| 132 | |
| 133 | // draw from vector marker |
| 134 | gl::setMatrices( cam ); |
| 135 | gl::color( 0, 1, 0.25f ); |
| 136 | gl::translate( mEarthSphere.getCenter() + mArcball.getFromVector() * mEarthSphere.getRadius() ); |
| 137 | mMarker->draw(); |
| 138 | |
| 139 | // draw to vector marker |
| 140 | gl::setMatrices( cam ); |
| 141 | gl::color( 1, 0.5f, 0.25f ); |
| 142 | gl::translate( mEarthSphere.getCenter() + mArcball.getToVector() * mEarthSphere.getRadius() ); |
| 143 | mMarker->draw(); |
| 144 | |
| 145 | // draw the elliptical axes |
| 146 | gl::setMatricesWindow( getWindowSize() ); |
| 147 | gl::color( 1, 0, 0 ); |
| 148 | vec2 center, axisA, axisB; |
| 149 | mCam.calcScreenProjection( mEarthSphere, getWindowSize(), ¢er, &axisA, &axisB ); |
| 150 | gl::drawLine( center - axisA, center + axisA ); |
| 151 | gl::drawLine( center - axisB, center + axisB ); |
| 152 | } |
| 153 | |
| 154 | CINDER_APP( ArcballTestApp, RendererGl ) |
nothing calls this directly
no test coverage detected