void SplatTestApp::setup() { resetCamera(); { connexion::Device::initialize(getRenderer()->getHwnd()); const auto &ids = connexion::Device::getAllDeviceIds(); if (!ids.empty()) { spaceNav = connexion::Device::create(ids.front()); spaceNav->getMotionSignal().connect([this](const connexion::MotionEvent &event) { cameraTranslation = event.translation; cameraRotation = event.rotation; }); spaceNav->getButtonDownSignal().connect( [this](const connexion::ButtonDownEvent &event) { resetCamera(); }); } } particleSys = std::make_unique<ParticleSys>(); particleUpdateMainFilepath = getAssetPath("update_cs.glsl"); wd::watch(particleUpdateMainFilepath, [this](const fs::path &filepath) { updateShaderError.clear(); try { particleSys->loadUpdateShaderMain(filepath); } catch (const gl::GlslProgCompileExc &exc) { updateShaderError = exc.what(); } }); ui::initialize(ui::Options().autoRender(false)); }
qavimator::qavimator(yarp::os::ResourceFinder &config, QWidget *parent) : QMainWindow(parent), ui(new Ui::qavimator) { ui->setupUi(this); setupToolBar(); ui->animationView->init(config); nFPS=10; width=850; height=600; readSettings(); // default size if (config.check("name")) { GUI_NAME=std::string(config.find("name").asString().c_str()); } if (GUI_NAME[0]!='/') { GUI_NAME=std::string("/")+GUI_NAME; } if (config.check("width")) { width=config.find("width").asInt(); } if (config.check("height")) { height=config.find("height").asInt(); } //sanity check if(width<100) { width=100; } if(height<100) { height=100; } this->resize(width, height); int xpos=32,ypos=32; if (config.check("xpos")) { xpos=config.find("xpos").asInt(); } if (config.check("ypos")) { ypos=config.find("ypos").asInt(); } this->move(xpos,ypos); setWindowTitle(GUI_NAME.c_str()); connect(ui->animationView,SIGNAL(backgroundClicked()),this,SLOT(backgroundClicked())); connect(this,SIGNAL(resetCamera()),ui->animationView,SLOT(resetCamera())); ui->animationView->startTimer(1000/nFPS); }
// // Initialize the application, loading all of the settings that // we will be accessing later in our fragment shaders. // void Setup() { // Set up lighting variables in OpenGL // Once we do this, we will be able to access them as built-in // attributes in the shader (see examples of this in normalmap.frag) glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glLightfv(GL_LIGHT0, GL_SPECULAR, specularLight); glLightfv(GL_LIGHT0, GL_AMBIENT, ambientLight); glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuseLight); surfaceNormImg = new STImage(normalMap); surfaceNormTex = new STTexture(surfaceNormImg); surfaceDisplaceImg = new STImage(displacementMap); surfaceDisplaceTex = new STTexture(surfaceDisplaceImg); surfaceColorImg = new STImage(colorMap); surfaceColorTex = new STTexture(surfaceColorImg); shader = new STShaderProgram(); shader->LoadVertexShader(vertexShader); shader->LoadFragmentShader(fragmentShader); resetCamera(); glClearColor(1.0f, 1.0f, 1.0f, 1.0f); glEnable(GL_DEPTH_TEST); gTriangleMesh=new STTriangleMesh(meshOBJ); if(proxyType) gTriangleMesh->CalculateTextureCoordinatesViaSphericalProxy(); else gTriangleMesh->CalculateTextureCoordinatesViaCylindricalProxy(-1,1,0,0,1); CreateYourOwnMesh(); }
OpenGLWidget::OpenGLWidget(QWidget *parent) : QGLWidget(parent), m_molecule(nullptr), m_angularSpeed(0) { resetCamera(); }
SimpleScene() { ipd = ovrHmd_GetFloat(hmd, OVR_KEY_IPD, OVR_DEFAULT_IPD); eyeHeight = ovrHmd_GetFloat(hmd, OVR_KEY_PLAYER_HEIGHT, OVR_DEFAULT_PLAYER_HEIGHT); if (!ovrHmd_ConfigureTracking(hmd, ovrTrackingCap_Orientation | ovrTrackingCap_Position | ovrTrackingCap_MagYawCorrection, 0)) { SAY_ERR("Could not attach to sensor device"); } for_each_eye([&](ovrEyeType eye){ textureIds[eye] = 0; }); memset(eyeTextures, 0, 2 * sizeof(ovrGLTexture)); float eyeHeight = 1.5f; player = glm::inverse(glm::lookAt( glm::vec3(0, eyeHeight, 4), glm::vec3(0, eyeHeight, 0), glm::vec3(0, 1, 0))); for_each_eye([&](ovrEyeType eye){ ovrSizei eyeTextureSize = ovrHmd_GetFovTextureSize(hmd, eye, hmd->MaxEyeFov[eye], 1.0f); ovrTextureHeader & eyeTextureHeader = eyeTextures[eye].Header; eyeTextureHeader.TextureSize = eyeTextureSize; eyeTextureHeader.RenderViewport.Size = eyeTextureSize; eyeTextureHeader.API = ovrRenderAPI_OpenGL; }); resetCamera(); }
virtual void onKey(int key, int scancode, int action, int mods) { if (!CameraControl::instance().onKey(key, scancode, action, mods)) { static const float ROOT_2 = sqrt(2.0f); static const float INV_ROOT_2 = 1.0f / ROOT_2; if (action == GLFW_PRESS) { switch (key) { case GLFW_KEY_HOME: if (0 == perEyeDelay) { perEyeDelay = 1; } else { perEyeDelay <<= 1; } return; case GLFW_KEY_END: perEyeDelay >>= 1; return; case GLFW_KEY_R: resetCamera(); return; case GLFW_KEY_P: { int caps = ovrHmd_GetEnabledCaps(hmd); if (caps & ovrHmdCap_LowPersistence) { ovrHmd_SetEnabledCaps(hmd, caps & ~ovrHmdCap_LowPersistence); } else { ovrHmd_SetEnabledCaps(hmd, caps | ovrHmdCap_LowPersistence); } } return; } } RiftGlfwApp::onKey(key, scancode, action, mods); } }
OGLViewer::OGLViewer(QWidget *parent) : QOpenGLWidget(parent), tcount(0), fps(30) , simp_lv(1) , m_selectMode(OBJECT_SELECT) { // Set surface format for current widget QSurfaceFormat format; format.setDepthBufferSize(32); format.setStencilBufferSize(8); format.setVersion(4, 5); format.setProfile(QSurfaceFormat::CoreProfile); this->setFormat(format); // Read obj file //box_mesh = new Mesh("../../scene/obj/cube_large.obj"); //model_mesh = new Mesh("../../scene/obj/monkey.obj"); #ifdef _DEBUG hds_box = new HDS_Mesh("../../scene/obj/frog.obj"); #else hds_box = new HDS_Mesh("quad_cube.obj"); #endif //hds_box->reIndexing(); //hds_box->validate(); simp_mesh = new Simplification(simp_lv, hds_box); resetCamera(); }
void resetScene() { resetCamera(); for (int i(0); i < NUM_TARGETS; i++) { allTargets[i]->respawn(); } }
/// /// main function TODO_DOCS_ /// @author matthew: TODO_AUTHOR_FULL_NAME_ /// /// @param argc number of command line arguments, including program name /// @param argv supplied command line arguments, including program name /// @returns errorCode the error Code; 0 if no error /// int main( int argc, char* argv[] ) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); glutInitWindowSize(1000, 500); glutCreateWindow(argv[0]); glEnable(GL_LIGHTING); // load textures TextureLoader::loadTextures(); // create scene LitScene theScene; sv = new StereoSceneViewport(theScene); sv->initProjection(60, 1, 40); sv->cam.updateScreenCenter(); resetCamera(); hud = new Hud(sv->cam); populateScene(theScene); // Final setup, including callbacks glClearColor(0,0,0,0); glutDisplayFunc(gldisplay); glutKeyboardFunc(glkeyboard); glutPassiveMotionFunc(glpassivemouse); glutMouseFunc(glmouse); glutTimerFunc(20, gltimer, 0); glutReshapeFunc(glreshape); glutMainLoop(); }
CubeScene::CubeScene() { ipd = ovrHmd_GetFloat(hmd, OVR_KEY_IPD, OVR_DEFAULT_IPD); eyeHeight = ovrHmd_GetFloat(hmd, OVR_KEY_PLAYER_HEIGHT, OVR_DEFAULT_PLAYER_HEIGHT); resetCamera(); }
void TrackballViewer::keyPressEvent(QKeyEvent *e) { // Get event modifiers key const Qt::KeyboardModifiers modifiers = e->modifiers(); // A simple switch on e->key() is not sufficient if we want to take state key into account. // With a switch, it would have been impossible to separate 'F' from 'CTRL+F'. // That's why we use imbricated if...else and a "handled" boolean. bool handled = false; if ((e->key()==Qt::Key_W) && (modifiers==Qt::NoButton)) { wireframe_ = !wireframe_; if (wireframe_) glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); else glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); handled = true; updateGL(); } else if ((e->key()==Qt::Key_R) && (modifiers==Qt::NoButton)) { resetCamera(); handled = true; updateGL(); } if (!handled) { QGLViewer::keyPressEvent(e); } }
PanoramicVideo::PanoramicVideo(ds::ui::SpriteEngine& engine) : ds::ui::Sprite(engine) , mVideoSprite(nullptr) , mInvertX(false) , mInvertY(true) , mXSensitivity(0.15f) , mYSensitivity(0.15f) , mFov(60.0f) , mAutoSync(true) , mPanning(0.0f) , mXRot(0.0f) , mYRot(-90.0f) { mBlobType = _BLOB; setUseShaderTexture(true); setTransparent(true); mSphereVbo = ci::gl::VboMesh::create(ci::geom::Sphere().subdivisions(120).radius(200.0f)); resetCamera(); enable(true); enableMultiTouch(ds::ui::MULTITOUCH_INFO_ONLY); setProcessTouchCallback([this](ds::ui::Sprite*, const ds::ui::TouchInfo& ti){ handleDrag(ci::vec2(ti.mDeltaPoint)); }); }
void RotationWidget::setUp(Storage *storage) { DataWidget::setUp(storage); contextMenu->addAction(tr("Load model..."), this, SLOT(loadModel())); contextMenu->addAction(tr("Reset camera"), this, SLOT(resetCamera())); }
OGLViewer::OGLViewer(QWidget *parent) : QOpenGLWidget(parent), tcount(0) , fps(30), timestep(1.0 / fps), isSim(false) { // Set surface format for current widget QSurfaceFormat format; format.setDepthBufferSize(32); format.setStencilBufferSize(8); format.setVersion(4, 5); format.setProfile(QSurfaceFormat::CoreProfile); this->setFormat(format); // Link timer trigger process_time.start(); QTimer *timer = new QTimer(this); /*timer->setSingleShot(false);*/ connect(timer, SIGNAL(timeout()), this, SLOT(update())); timer->start(0); // Read obj file #ifdef _DEBUG box_mesh = new Mesh("../../scene/obj/cube_huge.obj"); poly_mesh = new Mesh("../../scene/obj/bunny_simple.obj"); poly_bound = new Mesh("../../scene/obj/bunny_bound.obj"); #else box_mesh = new Mesh("cube_large.obj"); poly_mesh = new Mesh("bunny_simple.obj"); poly_bound = new Mesh("bunny_bound.obj"); #endif // _DEBUG poly_bound->refine(triangleList); mytree = new KdTreeAccel(triangleList); texW = sparkTex.getWidth(); texH = sparkTex.getHeight(); sparkTex.getPixelsRGBA(tex_pixels); // Initialize particle generators //Point3D newpos(0.0, 0.0, 0.0), vel(0.3, 1.0, 1.0), vel_var(0.3, 0.3, 0.3); ParticleGenerator* pg = new ParticleGenerator( 3500, 1000, 20, timestep, 3, 0.6, 2.0, 1.2, Point3D(0.0, 5.0, 0.0), Vector3D(0, -10, 0), Vector3D(1, 0, 0), ParticleGenerator::CONCENTRIC_DISK, 0.5); Vector3D* gravity = new Vector3D(0.0, -9.8, 0.0); Vector3D* wind = new Vector3D(0, 0.0, 0.0); pg->addForce(gravity); pg->addForce(wind); pgs.push_back(pg); pg->exportVBO(ptc_size, ptc_verts, ptc_vels, ptc_life, ptc_alive, true); pg->addCollision(mytree); resetCamera(); // Initialize transform matrix matrix.setIdentity();// setRotation(20, 0, 0); matrix.exportVBO(model_mat); }
void KeyCallback(unsigned char key, int x, int y) { switch(key) { case 's': { // // Take a screenshot, and save as screenshot.jpg // STImage* screenshot = new STImage(gWindowSizeX, gWindowSizeY); screenshot->Read(0,0); screenshot->Save("screenshot.jpg"); delete screenshot; } break; case 'r': resetCamera(); break; case 'u': resetUp(); break; case 'm': // switch between the mesh you create and the mesh from file mesh = !mesh; break; //case 'p': //switch proxy type between sphere and cylinder // proxyType=!proxyType; // if(proxyType) gTriangleMesh->CalculateTextureCoordinatesViaSphericalProxy(); // else gTriangleMesh->CalculateTextureCoordinatesViaCylindricalProxy(-1,1,0,0,1); // break; case 'n': // switch between normalMapping and displacementMapping normalMapping = !normalMapping; break; case 'f': // switch between smooth shading and flat shading smooth = !smooth; break; //case 'l': // do loop subdivision // if(mesh){ // gTriangleMesh->LoopSubdivide(); // if(proxyType) gTriangleMesh->CalculateTextureCoordinatesViaSphericalProxy(); // else gTriangleMesh->CalculateTextureCoordinatesViaCylindricalProxy(-1,1,0,0,1); // } // else // gManualTriangleMesh->LoopSubdivide(); // break; //case 'w': // gTriangleMesh->Write("output.obj"); // break; case 'a': for(unsigned int id=0;id<gTriangleMeshes.size();id++) gTriangleMeshes[id]->mDrawAxis=!gTriangleMeshes[id]->mDrawAxis; if(gManualTriangleMesh!=0) gManualTriangleMesh->mDrawAxis=!gManualTriangleMesh->mDrawAxis; break; case 'q': exit(0); default: break; } glutPostRedisplay(); }
void View::setDocument(Document *newDoc) { delete doc; doc = newDoc; resetCamera(); resetInteraction(); update(); }
void performKeyOperations() { bool pressed = false; if(keyStates['w'] == true) { angle[X_AXIS] -= 0.1; pressed = true; } if(keyStates['s'] == true) { angle[X_AXIS] += 0.1; pressed = true; } if(keyStates['d'] == true) { angle[Y_AXIS] -= 0.1; pressed = true; } if(keyStates['a'] == true) { angle[Y_AXIS] += 0.1; pressed = true; } if(keyStates['z'] == true) { angle[Z_AXIS] -= 0.1; pressed = true; } if(keyStates['c'] == true) { angle[Z_AXIS] += 0.1; pressed = true; } if(keyStates['o'] == true) { camDistance[Z_AXIS] -= 0.1; pressed = true; } if(keyStates['p'] == true) { camDistance[Z_AXIS] += 0.1; pressed = true; } if(keyStates['l'] == true) { camDistance[Y_AXIS] -= 0.1; pressed = true; } if(keyStates['k'] == true) { camDistance[Y_AXIS] += 0.1; pressed = true; } if(keyStates['m'] == true) { camDistance[X_AXIS] -= 0.1; pressed = true; } if(keyStates['n'] == true) { camDistance[X_AXIS] += 0.1; pressed = true; } if(keyStates['r'] == true) { resetCamera(); pressed=true; } if(pressed == true) { glutPostRedisplay(); } }
Camera::Camera(TransformFrame* parent) { resetCamera(); m_frame = new ManipulatedCameraTransformFrame(this, parent); m_frame->setPosition(Vec3f(0,0,-2)); setPivotPoint(Vec3f()); //m_frame->setReferenceFrame(parent); }
void OpenGLWidget::mouseDoubleClickEvent(QMouseEvent *) { m_angularSpeed = 0; m_rotation = QQuaternion(); resetCamera(); updateGL(); }
void GLWidget::clearScene() { pscene.clear(); // propagate to all plugins for (unsigned int i=0; i<plugins.size(); ++i) qobject_cast<BasicPlugin*>(plugins[i]->instance())->onSceneClear(); resetCamera(); }
/* * Performs specific initializations for this program (as opposed to * glut initialization. */ void myInit (int argc, char **argv) { /* Set the default display mode and style */ disp_mode = DM_CUBE_GLUT; disp_style = DS_SOLID; /* Set up a black background */ glClearColor(0.0, 0.0, 0.0, 0.0); resetCamera(); }
Camera::Camera(const Vec3f& position, const Quaternionf& orientation, TransformFrame* parent) { resetCamera(); m_frame = new ManipulatedCameraTransformFrame(this, parent); //m_frame->setReferenceFrame(parent); m_frame->setPosition(position); m_frame->setOrientation(orientation); if (position.x() != 0 && position.y() != 0 && position.z() != 0) setPivotPoint(Vec3f()); }
Camera::Camera(const Vec3f& direction, const Vec3f& up, const Vec3f& position, TransformFrame* parent) { resetCamera(); m_frame = new ManipulatedCameraTransformFrame(this, parent); //m_frame->setReferenceFrame(parent); m_frame->setPosition(position); this->setupCameraOrientation(direction, up); //if (position.x() != 0 && position.y() != 0 && position.z() != 0) setPivotPoint(direction * 2); }
void GLWidget::loadPlugins(const QStringList& list) { QStringList::ConstIterator it = list.constBegin(); while(it != list.constEnd()) { QString name = *it; QPluginLoader *loader = new QPluginLoader(name); if (! loader->load()) { qDebug() << "Could not load plugin " << name << "\n"; qDebug() << loader->errorString() << "\n"; } if (loader->isLoaded()) { qDebug() << "Loaded plugin: " << loader->fileName(); // << endl; QObject *plugin = loader->instance(); if (plugin) { plugins.push_back(loader); BasicPlugin *plugin = qobject_cast<BasicPlugin *>(loader->instance()); // initialize plugin if (plugin) { plugin->setWidget(this); plugin->setArgs(mainArgs); plugin->onPluginLoad(); if (plugin->drawScene()) // overrides drawScene? drawPlugin = plugin; } } } else { qDebug() << "Load error: " << name << endl; delete loader; } ++it; } // make sure all plugins know about the latest plugin that overrides drawScene for (unsigned int i=0; i<plugins.size(); ++i) { BasicPlugin *plugin = qobject_cast<BasicPlugin *>(plugins[i]->instance()); if (plugin) plugin->setDrawPlugin(drawPlugin); else { qDebug() << "Error: the plugin must implement the BasicPlugin interface" << endl << " Example: " << endl << " Q_INTERFACES(BasicPlugin)" << endl; } } resetCamera(); }
/*Key Pressed*/ void keyPressed(unsigned char key, int x, int y) { switch(key) { case 'r': resetCamera(); break; case 'w': drawWire=!drawWire; break; case 's': drawSolid=!drawSolid; break; } glutPostRedisplay(); }
ObjectRenderer::ObjectRenderer(Simulation* simulation, const std::string& object) : simulation(simulation), graphicsManager(simulation ? simulation->getGraphicsManager() : 0), object(object), simObject(simulation ? simulation->getObjectReference(object) : 0), width(0), height(0), focus(false), dragging(false), dragPlane(XY_PLANE), dragMode(KEEP_DYNAMICS) { resetCamera(); fovy = 40.0; fbo_reg = GLHelper::getGLH()->getFBOreg(); }
View::View(QWidget *parent) : QGLWidget(parent), doc(new Document), selectedBall(-1), oppositeSelectedBall(-1), mouseX(0), mouseY(0), mode(MODE_VIEW_MESH), #ifdef USE_SHADER_MATERIALS currentMaterial(0), #endif mirrorChanges(false), drawWireframe(true), drawInterpolated(true), drawCurvature(false), brushMode(BRUSH_ADD_OR_SUBTRACT), brushRadius(0), brushWeight(0), brushTool(NULL), currentCamera(&firstPersonCamera), drawToolDebug(false), currentTool(NULL) { resetCamera(); setMouseTracking(true); }
void Z3DCamera::resetCamera(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax, ResetCameraOptions options) { std::vector<double> bound(6); bound[0] = xmin; bound[1] = xmax; bound[2] = ymin; bound[3] = ymax; bound[4] = zmin; bound[5] = zmax; resetCamera(bound, options); }
/** * trata os eventos de pressionamento dos botões do mouse */ void RobotWindow::mouse(int button, int state, int x, int y) { mouseButton = button; mouseState = state; if(button == GLUT_LEFT_BUTTON) { if(state == GLUT_DOWN) { mouseX = x; mouseY = y; } else if(state == GLUT_UP) { } } else if(button == GLUT_MIDDLE_BUTTON) { resetCamera(); } }
TinyRendererVisualShapeConverter::TinyRendererVisualShapeConverter() { m_data = new TinyRendererVisualShapeConverterInternalData(); float dist = 1.5; float pitch = -80; float yaw = 10; float targetPos[3]={0,0,0}; m_data->m_camera.setCameraUpAxis(m_data->m_upAxis); resetCamera(dist,pitch,yaw,targetPos[0],targetPos[1],targetPos[2]); }