本文整理汇总了C++中Arcball类的典型用法代码示例。如果您正苦于以下问题:C++ Arcball类的具体用法?C++ Arcball怎么用?C++ Arcball使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Arcball类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getWindowBounds
void gpuPSApp::draw()
{
gl::setMatrices( mCam );
gl::setViewport( getWindowBounds() );
gl::clear( ColorA( 0.0f, 0.0f, 0.0f, 1.0f ) );
mFBO[mCurrentFBO].bindTexture(0,0);
mDisplShader.bind();
mDisplShader.uniform("displacementMap", 0 );
gl::pushModelView();
gl::translate( Vec3f( 0.0f, 0.0f, getWindowHeight() / 2.0f ) );
gl::rotate( mArcball.getQuat() );
gl::draw( mVboMesh );
gl::popModelView();
mDisplShader.unbind();
mFBO[mCurrentFBO].unbindTexture();
gl::setMatricesWindow(getWindowSize());
gl::drawString( toString( SIDE*SIDE ) + " vertices", Vec2f(32.0f, 32.0f));
gl::drawString( toString((int) getAverageFps()) + " fps", Vec2f(32.0f, 52.0f));
}
示例2: Color
void ArcballDemoApp::draw()
{
gl::clear( Color( 0, 0.1f, 0.2f ) );
if( mDrawVerbose )
drawVerbose();
else {
// the order of operations is important here - we don't want the rotation applied to the scale
// and likewise, we don't want the translation applied to the scale
// So the code below:
// 1) rotates the cube by the quaternion that arcball has provided
// 2) scales the cube to be 200 pixels big
// 3) moves the cube to the center of the window
gl::pushModelView();
glCullFace( GL_BACK );
gl::translate( getWindowSize() / 2.0f );
gl::scale( Vec3f( 200.0f, 200.0f, 200.0f ) );
gl::rotate( mArcball.getQuat() );
gl::drawColorCube( Vec3f::zero(), Vec3f( 1, 1, 1 ) );
gl::popModelView();
}
}
示例3: Color
void wellingtonModelApp::draw()
{
gl::enableDepthRead();
gl::enableDepthWrite();
gl::enableAlphaBlending();
// clear out the window with black
gl::clear( Color( 0, 0, 0 ) );
/*
if(mWaterModule != NULL){
gl::pushMatrices();
mWaterModule->draw();
gl::popMatrices();
}
*/
// /*
gl::setMatrices( mMayaCam.getCamera());
gl::pushMatrices();
myImage.enableAndBind();
gl::rotate( mArcball.getQuat() );
gl::scale(Vec3f(0.035,0.035,0.035));
glLineWidth(0.3f);
gl::enableWireframe();
gl::rotate(Vec3f(50.0, -20.0, 0.0));
gl::draw(mVbo);
myImage.unbind();
gl::popMatrices();
// */
}
示例4: Color
void ObjLoaderApp::draw()
{
gl::enableDepthWrite();
gl::enableDepthRead();
gl::clear( Color( 0.0f, 0.1f, 0.2f ) );
glDisable( GL_CULL_FACE );
gl::setMatrices( mMayaCam.getCamera() );
/* Sphere boundingSphere = Sphere::calculateBoundingSphere( mMesh.getVertices() );
glColor3f( 1.0f, 1.0f, 1.0f );
gl::disableDepthWrite();
mTexture->disable();
mShader.unbind();
gl::draw( boundingSphere, 30 );
gl::enableDepthWrite();
*/
mShader.bind();
gl::pushMatrices();
gl::rotate( mArcball.getQuat() );
gl::draw( mVBO );
gl::popMatrices();
}
示例5: mouseDown
void BasicShaderIIApp::mouseDown( MouseEvent event )
{
mArcball.mouseDown( event.getPos() );
}
示例6: getWindowSize
void fsExperiments::resize( ResizeEvent event )
{
mArcball.setWindowSize( getWindowSize() );
mArcball.setCenter( getWindowCenter() );
mArcball.setRadius( 150 );
}
示例7: mouseDrag
void fsExperiments::mouseDrag( MouseEvent event )
{
mArcball.mouseDrag( event.getPos() );
}
示例8: mouseDrag
void BasicApp::mouseDrag( MouseEvent event )
{
mArcball.mouseDrag( event.getPos() );
}
示例9: mouseDrag
void ArcballDemoApp::mouseDrag( MouseEvent event )
{
mArcball.mouseDrag( event.getPos() );
mCurrentMouseDown = event.getPos();
}
示例10: mouseDrag
void CinderProjectionTestApp::mouseDrag( MouseEvent event )
{
mArcball.mouseDrag( event.getPos() );
}
示例11: main
int main(int argc, const char * argv[]) {
if( !glfwInit() ) {
cerr << "Unable to initialize glfw" << endl;
return false;
}
/* Tell GLFW to use OpenGL 4.1 */
glfwWindowHint( GLFW_CONTEXT_VERSION_MAJOR, 4 );
glfwWindowHint( GLFW_CONTEXT_VERSION_MINOR, 1 );
glfwWindowHint( GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE );
glfwWindowHint( GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE );
GLFWwindow * window = glfwCreateWindow( WINDOW_WIDTH, WINDOW_HEIGHT, "Arcball", NULL, NULL );
if ( !window ) {
cerr << "Unable to create glfw window" << endl;
glfwTerminate();
return false;
}
glfwMakeContextCurrent( window );
glfwSetInputMode( window, GLFW_STICKY_KEYS, GL_TRUE );
cout << "OpenGL Ver: " << glGetString( GL_VERSION ) << endl;
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glShadeModel( GL_SMOOTH );
glEnable( GL_DEPTH_TEST );
glDepthFunc( GL_LESS );
glFrontFace( GL_CCW );
glEnable( GL_CULL_FACE );
glCullFace( GL_BACK );
/* Set the callback functions */
glfwSetErrorCallback( errorCallback );
glfwSetScrollCallback( window, scrollCallback );
glfwSetKeyCallback( window, keyCallback );
glfwSetFramebufferSizeCallback( window, frameBufferSizeCallback );
glfwSetCursorPosCallback( window, cursorCallback );
glfwSetMouseButtonCallback( window, mouseButtonCallback );
GLuint vertex_array_id;
glGenVertexArrays( 1, &vertex_array_id );
glBindVertexArray( vertex_array_id );
Shader shader( "simpleLighting.vsh", "simpleLighting.fsh" );
GLuint cube_buffers[2];
glGenBuffers( 2, cube_buffers );
glBindBuffer( GL_ARRAY_BUFFER, cube_buffers[0] );
glBufferData( GL_ARRAY_BUFFER, sizeof(glm::vec3) * cube_buffer_data.size(), &cube_buffer_data[0], GL_STATIC_DRAW );
glBindBuffer( GL_ARRAY_BUFFER, cube_buffers[1] );
glBufferData( GL_ARRAY_BUFFER, sizeof(glm::vec3) * cube_normals_data.size(), &cube_normals_data[0], GL_STATIC_DRAW );
GLuint floor_buffers[2];
glGenBuffers( 2, floor_buffers );
glBindBuffer( GL_ARRAY_BUFFER, floor_buffers[0] );
glBufferData( GL_ARRAY_BUFFER, sizeof(glm::vec3) * floor_buffer_data.size(), &floor_buffer_data[0], GL_STATIC_DRAW );
glBindBuffer( GL_ARRAY_BUFFER, floor_buffers[1] );
glBufferData( GL_ARRAY_BUFFER, sizeof(glm::vec3) * floor_normals_data.size(), &floor_normals_data[0], GL_STATIC_DRAW );
glm::mat4 model = glm::mat4(1.0);
glm::mat4 view = glm::lookAt( glm::vec3(0.0f, 0.0f, 3.0f), glm::vec3(0., 0., 0.), glm::vec3(0., 1., 0.) );
glm::mat4 projection = glm::perspective(70.0f, 4.0f/3.0f, 0.1f, 100.0f );
glm::vec3 light_position = glm::vec3( 4, 4, 4 );
shader.bind();
shader.setUniform( "light_position_w", light_position );
while( !glfwWindowShouldClose( window )){
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
{ /* Draw on 1st viewport, show rotation of the camera */
glViewport( 0, 0, WINDOW_WIDTH / 2, WINDOW_HEIGHT );
glm::mat4 rotated_view = view * arcball.createViewRotationMatrix();
glm::mat4 mvp = projection * rotated_view * model;
shader.setUniform( "light_color", glm::vec3(1.0, 1.0, 0.0) );
shader.setUniform( "v", rotated_view );
shader.setUniform( "m", model );
shader.setUniform( "mvp", mvp );
/* Draw cube */
glEnableVertexAttribArray( 0 );
glBindBuffer( GL_ARRAY_BUFFER, cube_buffers[0] );
glVertexAttribPointer( 0, 3, GL_FLOAT, GL_FALSE, 0, (void*) 0 );
glEnableVertexAttribArray( 1 );
glBindBuffer( GL_ARRAY_BUFFER, cube_buffers[1] );
glVertexAttribPointer( 1, 3, GL_FLOAT, GL_FALSE, 0, (void*) 0 );
glEnable( GL_CULL_FACE );
glDrawArrays( GL_TRIANGLE_STRIP, 0, static_cast<int>(cube_buffer_data.size()) );
/* Draw the floor, with different color */
shader.setUniform( "light_color", glm::vec3(0.0, 1.0, 1.0) );
glEnableVertexAttribArray( 0 );
//.........这里部分代码省略.........
示例12: getWindowSize
void camerasApp::resize()
{
mArcball.setWindowSize( getWindowSize() );
mArcball.setCenter( getWindowCenter() );
mArcball.setRadius( 150 );
}
示例13: getWindowSize
void ArcballDemoApp::resize( int width, int height )
{
mArcball.setWindowSize( getWindowSize() );
mArcball.setCenter( getWindowCenter() );
mArcball.setRadius( 150 );
}
示例14: mouseDrag
void gpuPSApp::mouseDrag( MouseEvent event )
{
mArcball.mouseDrag( event.getPos() );
}
示例15: Color
void CinderProjectionTestApp::draw()
{
// clear out the window with black
gl::clear( Color( 0, 0, 0 ), true );
gl::enableDepthRead();
gl::enableDepthWrite();
//gl::enableAlphaBlending();
if ( mActiveCam == CAM_LOOK )
{
gl::setMatrices( mLookCam );
gl::rotate( mArcball.getQuat() );
}
else if ( mActiveCam == CAM_SWEET )
gl::setMatrices( mSweetCam );
else if ( mActiveCam == CAM_PROJ )
gl::setMatrices( mProjCam );
// Green = Cam from 'sweet spot'
gl::color( Color( 0, 1, 0 ) );
gl::drawFrustum( mSweetCam );
// Cyan = Cam from projector
gl::color( Color( 0, 1, 1 ) );
gl::drawFrustum( mProjCam );
// Draw a grid in the yz plane
gl::color( Color( 0.2f, 0.2f, 0.2f ) );
gl::pushMatrices();
gl::scale(Vec3f::one() /5 );
for (int i=0; i<=20; ++i)
{
gl::drawLine(Vec3f(-100.0f+(i*10.0f), 0.0f, -100.0f),Vec3f(-100.0f+(i*10.0f), 0.0f, 100.0f));
gl::drawLine(Vec3f(-100.0f, 0.0f, -100.0f+(i*10.0f)),Vec3f(100.0f, 0.0f, -100.0f+(i*10.0f)));
}
gl::popMatrices();
gl::color( Color::white() );
//glEnable( GL_LIGHTING );
//glEnable( GL_LIGHT0 );
//GLfloat light_position[] = { mMousePos.x, mMousePos.y, 75.0f, 1.0f };
//glLightfv( GL_LIGHT0, GL_POSITION, light_position );
// Bind texture, so it will be avaible to the fragment shader.
mTexture.bind();
// Bind the texture projection shader, let the magic happen!
mProjShader.bind();
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
mProjShader.uniform("projMap", 0);
mProjShader.uniform("TexGenMat", mSweetCam.getProjectionMatrix() );
mProjShader.uniform("InvViewMat", mProjCam.getInverseModelViewMatrix() );
mProjShader.uniform("texScaling", mTextureScaling );
//mProjShader.uniform("alpha", 0.6f );
//mProjShader.uniform("scaling", 10.0f );
gl::pushModelView();
//gl::rotate( Vec3f( 0.0f, 45.0f, 0.0f ) );
gl::rotate( mCubeRotation );
gl::translate( Vec3f(0.0f, 0.5f * mCubeSize, 0.0f) );
gl::drawColorCube( Vec3f::zero(), Vec3f::one() * mCubeSize );
gl::popModelView();
mProjShader.unbind();
mTexture.unbind();
glDisable( GL_LIGHTING );
gl::color( Color::white() );
// Draw the interface
params::InterfaceGl::draw();
}