Ejemplo n.º 1
0
void Camera::rotate(float angle, const Vector3& axis)
{
	Matrix44 R;
	R.setRotation(angle,axis);
	Vector3 new_front = R * (center - eye);
	center = eye + new_front;
	updateViewMatrix();
}
Ejemplo n.º 2
0
void Camera::setAxes(const Vec3& right, const Vec3& up, const Vec3& front) {
    m_right = right;
    m_up = up;
    m_front = front;
    updateViewMatrix();
    updateViewProjectionMatrix();
	updateFrustumPlanesAndPoints();
}
Ejemplo n.º 3
0
    // updates only if needed
    const Mat44& Camera::getViewMatrix()
    {
        if (mMatrixUpdateFlags) {
            updateViewMatrix();
        }

        return mViewMatrix;
    }
Ejemplo n.º 4
0
void Camera::Lookat(Mesh* mesh)
{
    unsigned int mid_index = mesh->vertex_number_/2;

    EigenVector3 lookat = mesh->vec_current_position_.block_vector(mid_index);
    m_lookat = glm::vec3(lookat[0], lookat[1], lookat[2]);
    updateViewMatrix();
}
Ejemplo n.º 5
0
void Camera::lookAt(const Vector3& eye, const Vector3& center, const Vector3& up)
{
	this->eye = eye;
	this->center = center;
	this->up = up;

	updateViewMatrix();
}
Ejemplo n.º 6
0
void Camera::onLateUpdate()
{
	if (dImpl->dirty)
	{
		updateViewMatrix();
		dImpl->dirty = false;
	}
}
Ejemplo n.º 7
0
	void ShadowManager::addShadowLight(Light *const light)
	{
		light->addObserver(this, Light::MOVE);

		shadowDatas[light] = new ShadowData(light, nbShadowMaps);

		createShadowMaps(light);
		updateViewMatrix(light);
	}
Ejemplo n.º 8
0
void CCAMERA::ResetXYpos()
{
    m_parametersChanged = true;
    m_camera_pos.x = 0.0f;
    m_camera_pos.y = 0.0f;

    updateViewMatrix();
    updateFrustum();
}
Ejemplo n.º 9
0
void Camera::MouseChangeLookat(float coe, float dx, float dy)
{
    glm::vec3 vdir(m_lookat - m_position);
    glm::vec3 u(glm::normalize(glm::cross(vdir, m_up)));
    glm::vec3 v(glm::normalize(glm::cross(u, vdir)));

    m_lookat += coe * (dy * v - dx * u);
    updateViewMatrix();
}
Ejemplo n.º 10
0
void CCAMERA::ZoomReset()
{
    m_zoom = 1.0f;

    m_camera_pos.z = m_camera_pos_init.z;

    updateViewMatrix();
    rebuildProjection();
}
Ejemplo n.º 11
0
const Matrix4& Camera::getViewMatrix()
{
    if (m_isMatViewDirty) {
        updateViewMatrix();
        m_isMatViewDirty = false;
    }
    
    return m_matView;
}
Ejemplo n.º 12
0
CWBOOL cwOrthoCamera::init()
{
	if (!cwCamera::init()) return CWFALSE;

	m_nPos = cwVector3D(0.0f, 0.0f, -10.0f);
	updateViewMatrix();

	return CWTRUE;
}
Ejemplo n.º 13
0
	void ShadowManager::onResize(int width, int height)
	{
		sceneWidth = width;
		sceneHeight = height;

		for(std::map<const Light *, ShadowData *>::const_iterator it = shadowDatas.begin(); it!=shadowDatas.end(); ++it)
		{
			updateViewMatrix(it->first);
		}
	}
Ejemplo n.º 14
0
 /**
  * @brief Resets trackball to initial position and orientation
  */
 void reset (void)
 {
     quaternion = Eigen::Quaternion<float>::Identity();
     zoom = 1.0;
     translationVector << 0.0, 0.0, 0.0;
     rotating = false;
     translating = false;
     Camera::reset();
     updateViewMatrix();
 }
Ejemplo n.º 15
0
	/**
	*	Set the position at which the camera is looking and update its rendering matrices accordingly
	*	@author Serge Radinovich
	*	@param  _pTarget		New target of the camera
	*/
	void Camera::lookAt(const D3DXVECTOR3*  _pTarget)
	{
		m_lookPos = *_pTarget;

		D3DXVECTOR3 _look = m_lookPos - m_transform.translation;
		D3DXVec3Normalize(&_look, &_look);

		Transform::setForward(&m_transform, &_look);

		updateViewMatrix();
	}
Ejemplo n.º 16
0
void updateEditorCamera(void)
{
	camera_struct* c=&editorCamera;

	c->viewPosition=c->position;
	
	updateViewMatrix(c);
	updateFrustum(c);
	
	fixMatrix(c->transformationMatrix);
}
Ejemplo n.º 17
0
    /**
     * @brief Resets camera to initial position and orientation
     */
    void reset (void) override
    {
		start_mouse_pos = Eigen::Vector2f::Zero();
		rotation_matrix = Eigen::Matrix3f::Identity();
		default_translation = Eigen::Vector3f (0.0, 0.0, -2.0);
		translation_vector = default_translation;
        rotation_X_axis = 0.0;
        rotation_Y_axis = 0.0;
		rotation_Z_axis = 0.0;
		updateViewMatrix();
    }
Ejemplo n.º 18
0
void Camera::set()
{
	updateViewMatrix();
	updateProjectionMatrix();

	glMatrixMode( GL_MODELVIEW );
	glLoadMatrixf( view_matrix.m );
	glMatrixMode( GL_PROJECTION );
	glLoadMatrixf( projection_matrix.m );
	glMatrixMode( GL_MODELVIEW );
}
Ejemplo n.º 19
0
Camera::Camera(vec3 pos, float horiAngle, float vertAngle, float aspectRatio, float fovy, float viewDistance) :
	position(pos)
{
	this->verticalAngle = vertAngle;
	this->horizontalAngle = horiAngle;
	this->aspect = aspectRatio;
	this->fovy = fovy;
	this->viewDistance = viewDistance;
	updateViewMatrix();
	updateProjectionMatrix();
}
Ejemplo n.º 20
0
void Camera::move(const D3DXVECTOR3 &direction, const D3DXVECTOR3 &amount)
{
    // Moves the camera by the specified amount of world units in the specified
    // direction in world space.

    m_eye.x += direction.x * amount.x;
    m_eye.y += direction.y * amount.y;
    m_eye.z += direction.z * amount.z;

    updateViewMatrix(false);
}
Ejemplo n.º 21
0
void DeferredRendererOld::refresh()
{
  if(shader_->isModified())
    updateShader();

  mesh_.refresh();
  sceneBox_.refresh();
  camera_->update();
  quadRender_.refresh();
  updateViewMatrix();
}
Ejemplo n.º 22
0
///////////////////////////////////////////////////////////////////////////////
// set the camera position and rotation
///////////////////////////////////////////////////////////////////////////////
void ModelGL::setViewMatrix(float x, float y, float z, float pitch, float heading, float roll)
{
    cameraPosition[0] = x;
    cameraPosition[1] = y;
    cameraPosition[2] = z;
    cameraAngle[0] = pitch;
    cameraAngle[1] = heading;
    cameraAngle[2] = roll;

    updateViewMatrix();
}
Ejemplo n.º 23
0
    void rotate(const glm::vec2& delta) {

        // create orientation vectors
        auto lookat = orientation * Vectors::UNIT_NEG_Z;
        auto forward = glm::normalize(vec3(lookat.x, 0, lookat.z));
        auto side = glm::cross(Vectors::UP, forward);

        // rotate camera with quaternions created from axis and angle
        orientation = glm::angleAxis(delta.x, Vectors::UP) * orientation;
        orientation = glm::angleAxis(-delta.y, side) * orientation;
        updateViewMatrix();
    }
Ejemplo n.º 24
0
CWVOID cwCamera::lookAt(const cwVector3D& pos, const cwVector3D& target, const cwVector3D& up)
{
	m_nLook = target - pos;
	m_nLook.normalize();
	m_nRight = up.cross(m_nLook);
	m_nRight.normalize();
	m_nUp = m_nLook.cross(m_nRight);
	
	m_nPos = pos;

	updateViewMatrix();
}
Ejemplo n.º 25
0
void PlotGl::mouseMoveEvent(QMouseEvent *pEvt)
{
	bool bUpdateView = 0;
	if(m_bMouseRotateActive)
	{
		t_real_gl dNewX = t_real_gl(pEvt->POS_F().x());
		t_real_gl dNewY = t_real_gl(pEvt->POS_F().y());

		m_dMouseRot[0] += dNewX - m_dMouseBegin[0];
		m_dMouseRot[1] += dNewY - m_dMouseBegin[1];

		m_dMouseBegin[0] = dNewX;
		m_dMouseBegin[1] = dNewY;

		bUpdateView = 1;
	}

	if(m_bMouseScaleActive)
	{
		t_real_gl dNewY = t_real_gl(pEvt->POS_F().y());

		m_dMouseScale *= 1.-(dNewY - m_dMouseScaleBegin)/t_real_gl(height()) * 2.;
		m_dMouseScaleBegin = dNewY;

		bUpdateView = 1;
	}

	if(bUpdateView)
		updateViewMatrix();


	m_dMouseX = 2.*pEvt->POS_F().x()/t_real_gl(m_iW) - 1.;
	m_dMouseY = -(2.*pEvt->POS_F().y()/t_real_gl(m_iH) - 1.);

	bool bHasSelected = 0;
	if(m_bEnabled.load())
	{
		mouseSelectObj(m_dMouseX, m_dMouseY);

		for(PlotObjGl& obj : m_vecObjs)
		{
			if(obj.bSelected)
			{
				m_sigHover(&obj);
				bHasSelected = 1;
				break;
			}
		}
	}
	if(!bHasSelected)
		m_sigHover(nullptr);
}
Ejemplo n.º 26
0
Camera::Camera(GLFWwindow *window) {
	m_window = window;
	getWindowDimensions();
	centerMouse();

	initVars();

	setCenter(glm::vec3(0, 0, 5));
	setLookAt(glm::vec3(0, 0, 4));
	setUp(glm::vec3(0, 1, 0));
	setRight(glm::vec3(1, 0, 0));
	updateViewMatrix();
}
Ejemplo n.º 27
0
xtCamera::xtCamera(void)
{
	//this->matrixView.identity();
	for ( int i=0; i<3; ++i ) {
		this->cameraPosition[i] = 0.0;
	}

	this->cameraAngle[0] = CAMERA_ANGLE_X;
	this->cameraAngle[1] = CAMERA_ANGLE_Y;
	this->cameraAngle[2] = 0.0f;

	updateViewMatrix();
}
Ejemplo n.º 28
0
CWVOID cwCamera::roll(CWFLOAT fRadian)
{
	cwMatrix4X4 matRot;
	matRot.setRotation(m_nLook, fRadian);

	m_nUp *= matRot;
	m_nRight *= matRot;

	m_nUp.normalize();
	m_nRight.normalize();

	updateViewMatrix();
}
Ejemplo n.º 29
0
	void ShadowManager::notify(Observable *observable, int notificationType)
	{
		if(dynamic_cast<LightManager *>(observable))
		{
			Light *light = lightManager->getLastUpdatedLight();
			switch(notificationType)
			{
				case LightManager::ADD_LIGHT:
				{
					light->addObserver(this, Light::PRODUCE_SHADOW);

					if(light->isProduceShadow())
					{
						addShadowLight(light);
					}
					break;
				}
				case LightManager::REMOVE_LIGHT:
				{
					light->removeObserver(this, Light::PRODUCE_SHADOW);

					if(light->isProduceShadow())
					{
						removeShadowLight(light);
					}
					break;
				}
			}
		}else if(Light *light = dynamic_cast<Light *>(observable))
		{
			switch(notificationType)
			{
				case Light::MOVE:
				{
					updateViewMatrix(light);
					break;
				}
				case Light::PRODUCE_SHADOW:
				{
					if(light->isProduceShadow())
					{
						addShadowLight(light);
					}else
					{
						removeShadowLight(light);
					}
					break;
				}
			}
		}
	}
Ejemplo n.º 30
0
void Camera::orbit( const Vector3& center, float angle, const Vector3& axis )
{
	Matrix44 R;
	R.setRotation(angle,axis);
	Matrix44 T;
	T.setTranslation( center.x, center.y, center.z );
	Matrix44 M = T * R;
	T.setTranslation( -center.x, -center.y, -center.z );
	M = M * T;

	this->center = M * this->center;
	this->eye = M * this->eye;
	updateViewMatrix();
}