/*! \brief Initialize the RenderWindowInteractor This function is called from the two constructors */ void RenderWindowInteractor::InitRenderWindowInteractor() { this->SetLeftButtonFunction( SLOT(CameraRotate()) ); this->SetMiddleButtonFunction( SLOT(CameraTranslate()) ); this->SetRightButtonFunction( SLOT(CameraZoom()) ); this->SetShiftLeftButtonFunction( SLOT(CameraRoll()) ); this->mouseEventActive = false; this->SetInteractionTime( 50 ); this->SetSensitivity( 10.0 ); this->stepTimer = new QTimer(); CHECK_PTR( this->stepTimer ); this->currentCamera = this->GetRenderer()->GetActiveCamera(); CHECK_PTR( this->currentCamera ); // get the light we are using vtkLightCollection *lightCollection = this->GetRenderer()->GetLights(); lightCollection->InitTraversal(); this->currentLight = lightCollection->GetNextItem(); CHECK_PTR( this->currentLight ); this->interactionActor = NULL; this->collisionActor = NULL; }
PyObject* LMF_CameraRotate(PyObject *self, PyObject *args){ float fRot; if (!PyArg_ParseTuple(args, "f", &fRot)) { ParsePyTupleError( __func__, __LINE__ ); return nullptr; } CameraRotate(fRot); Py_RETURN_NONE; }
// инициализаця OpenGL bool GLWindowInit(const GLWindow *window) { ASSERT(window); // устанавливаем вьюпорт на все окно glViewport(0, 0, window->width, window->height); // параметры OpenGL glClearColor(0.0f, 0.0f, 0.0f, 1.0f); glClearDepth(1.0f); glEnable(GL_DEPTH_TEST); // создадим и загрузим шейдерную программу if ((shaderProgram = ShaderProgramCreateFromMemory(vertexShader, fragmentShader)) == 0) return false; // собираем созданную и загруженную шейдерную программу if (!ShaderProgramLink(shaderProgram)) return false; // сделаем шейдерную программу активной ShaderProgramBind(shaderProgram); // проверка шейдерной программы на корректность if (!ShaderProgramValidate(shaderProgram)) return false; // создадим примитив для сферы MeshCreateSphere(mesh, vec3(0.0f, 0.0f, 0.0f), 1.0f); // создадим и настроим камеру CameraCreate(mainCamera, -1.0f, -1.0f, -1.0f); CameraOrthographic(mainCamera, -0.5f, 0.5f, -0.5f, 0.5f, -10.0f, 10.0f); CameraRotate(mainCamera, (float)(-math_degrees * asin((double)1/sqrt(3.0))), 135.0f, 0.0f); // проверим не было ли ошибок OPENGL_CHECK_FOR_ERRORS(); return true; }