MCPcopy Create free account
hub / github.com/cinder/Cinder / draw

Method draw

test/SphereProjection/src/SphereProjectionApp.cpp:90–152  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

88}
89
90void SphereProjectionApp::draw()
91{
92 gl::enableDepthRead();
93 gl::enableDepthWrite();
94 gl::enableAlphaBlending();
95
96 gl::setMatrices( mCam );
97 gl::clear( Color( 0, 0, 0 ) );
98
99 gl::color( 1, 1, 1 );
100 mPlaneBatch->draw();
101
102 gl::color( 1, 0, 0 );
103 gl::drawSphere( mSpherePositions[0], mSphereRadii[0], 40 );
104 gl::color( 0, 1, 0 );
105 gl::drawSphere( mSpherePositions[1], mSphereRadii[1], 40 );
106 gl::color( 0, 0, 1 );
107 gl::drawSphere( mSpherePositions[2], mSphereRadii[2], 40 );
108
109 gl::setMatricesWindow( getWindowSize() );
110
111 for( int i = 0; i < 3; ++i ) {
112 vec3 cameraSpaceSpherePos( mCam.getViewMatrix() * vec4( mSpherePositions[i], 1 ) );
113 vec2 center, axisA, axisB;
114 Sphere worldSpaceSphere( mSpherePositions[i], mSphereRadii[i] );
115 Sphere cameraSpaceSphere( cameraSpaceSpherePos, mSphereRadii[i] );
116 cameraSpaceSphere.calcProjection( mCam.getFocalLength(), &center, &axisA, &axisB );
117
118 // draw ellipse projection
119 gl::color( 1, 1, 0 );
120 gl::disableDepthRead();
121 gl::drawSolidCircle( clipToScreenCoords( center ), 4.0f );
122 gl::drawLine( clipToScreenCoords( center - axisA ), clipToScreenCoords( center + axisA ) );
123 gl::drawLine( clipToScreenCoords( center - axisB ), clipToScreenCoords( center + axisB ) );
124 gl::color( 1, 1, 1, 1 );
125
126 // draw bounding circle
127 mCam.calcScreenProjection( worldSpaceSphere, getWindowSize(), &center, &axisA, &axisB );
128 gl::drawStrokedCircle( center, std::max( length( axisA ), length( axisB ) ) );
129 }
130
131 ImGui::ScopedWindow window( "Sphere Projection Controls" );
132 float fov = mFov;
133 if( ImGui::SliderFloat( "Field of View", &fov, 1.0f, 120.0f, "%.1f deg" ) )
134 mFov = fov;
135
136 bool paused = mTimer.isStopped();
137 if( ImGui::Checkbox( "Pause Animation", &paused ) ) {
138 if( paused )
139 mTimer.stop();
140 else
141 mTimer.resume();
142 }
143
144 if( ImGui::Button( "Frame Sphere 1" ) )
145 mCam = mCam.calcFraming( Sphere( mSpherePositions[0], mSphereRadii[0] ) );
146 ImGui::SameLine();
147 if( ImGui::Button( "Sphere 2" ) )

Callers

nothing calls this directly

Calls 15

enableDepthReadFunction · 0.85
enableDepthWriteFunction · 0.85
enableAlphaBlendingFunction · 0.85
setMatricesFunction · 0.85
drawSphereFunction · 0.85
setMatricesWindowFunction · 0.85
disableDepthReadFunction · 0.85
drawSolidCircleFunction · 0.85
drawStrokedCircleFunction · 0.85
lengthFunction · 0.85
getFocalLengthMethod · 0.80
calcScreenProjectionMethod · 0.80

Tested by

no test coverage detected