Esempio n. 1
0
void Camera :: slide(float delU, float delV, float delN)
{
	eye.x += delU * u->x + delV * v->x + delN * n->x;
	eye.y += delU * u->y + delV * v->y + delN * n->y;
	eye.z += delU * u->z + delV * v->z + delN * n->z;
	setModelViewMatrix();
}
//<<<<<<<<<<<<<<<<<<<<<<<< roll >>>>>>>>>>>>>>>>>>>>>>>>>>> 
void Camera :: roll(float angle) 
{ 

	rotAxes( u, v, angle ); 

    setModelViewMatrix(); 
}
Esempio n. 3
0
void Camera:: slide(GLdouble delU, GLdouble delV, GLdouble delN) // slide the camera along its own axes
{
	eye.x += delU * u.x + delV * v.x + delN * n.x;
	eye.y += delU * u.y + delV * v.y + delN * n.y;
	eye.z += delU * u.z + delV * v.z + delN * n.z;
	setModelViewMatrix(); // tell OpenGL 
}
Esempio n. 4
0
void Camara::Oblicua(GLfloat xLeft,GLfloat xRight,GLfloat yBot,GLfloat yTop,GLfloat N,GLfloat F,PV3D* direccion){
    glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	glOrtho(xLeft,xRight, yBot,yTop, N,F);
    float matriz[16];
	matriz[0] = 1;
	matriz[1] = 0;
	matriz[2] = 0;
	matriz[3] = 0;
	matriz[4] = 0;
	matriz[5] = 1;
	matriz[6] = 0;
	matriz[7] = 0;
	matriz[8] = (-direccion->getX()/(GLdouble)direccion->getZ());
	matriz[9] = (-direccion->getY()/(GLdouble)direccion->getZ());
	matriz[10] = 1;
	matriz[11] = 0;
	matriz[12] = 0;
	matriz[13] = 0;
	matriz[14] = 0;
	matriz[15] = 1;
	glMultMatrixf(matriz);
	setModelViewMatrix();
    delete direccion;
}
Esempio n. 5
0
void Camera :: rotate(Vector3* axis, float angle)
{
	float cs = cos(3.14159265/180 * angle);
	float sn = sin(3.14159265/180 * angle);

	Vector3* t;
	Vector3* s;
	if(axis == v) {
		t = u;
		s = n;
	}
	else if(axis == u) {
		t = n;
		s = v;
	}
	else if(axis == n) {
		t = u;
		s = v;
	}

	Vector3* temp = new Vector3(t);

	t->set(cs*t->x + sn*s->x, cs*t->y + sn*s->y, cs*t->z + sn*s->z);
	s->set(cs*s->x - sn*temp->x, cs*s->y - sn*temp->y, cs*s->z - sn*temp->z);
	setModelViewMatrix();
}
Esempio n. 6
0
void display(void)
{
	glEnable(GL_CULL_FACE);
	glCullFace(GL_BACK);

	if( m_pDemo->m_enableLighting )
	{
		glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
	}
	else
	{
		glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );
	}

	glLoadIdentity();
	{
		setPerspectiveProjMatrix();
		setModelViewMatrix();
	}
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	
	glColor3f(1, 1, 1);

	if( m_pDemo->m_enableLighting )
	{
		glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );

		glEnable(GL_COLOR_MATERIAL);
		glEnable(GL_NORMALIZE);
		glEnable(GL_LIGHTING);
		glEnable(GL_LIGHT0);
		float lightPos[] = {0,2,2,1};
		glLightfv(GL_LIGHT0, GL_POSITION, lightPos);
		float s = 0.3f;
		float ambColor[] = {s,s,s,1.f};
		glLightfv(GL_LIGHT0, GL_AMBIENT, ambColor);
	}
	else
	{
		glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );
	}

	drawDemo();

	if( m_pDemo->m_enableLighting )
	{
		glDisable(GL_LIGHT0);
		glDisable(GL_LIGHTING);
	}

	if( drawText )
	{
		setOrthoProjMatrix();
		glLoadIdentity();
		drawDemo2D();
	}

	glutSwapBuffers();
}
void Camera:: yaw(GLdouble angle) { //yaw the camera through angle degrees
	GLdouble cs = cos(3.14159265 /180 * angle);
	GLdouble sn = sin(3.14159265 /180 * angle);
	Vector3 t(n); //remember old u
	n.set(cs*t.x + sn*u.x, cs*t.y + sn*u.y, cs*t.z + sn*u.z);
	u.set(-sn*t.x + cs*u.x, -sn*t.y + cs*u.y, -sn*t.z + cs*u.z);
	setModelViewMatrix();	
}
void Camera:: set(Point3 Eye, Point3 look, Vector3 up) {      // create a modelview matrix and send it to OpenGL
	eye.set(Eye);                                          // store the given eye position
	n.set(eye.x - look.x, eye.y - look.y, eye.z - look.z); // make n
	u.set(up.cross(n));                                    // make u = up X n
	n.normalize(); u.normalize();                          // make them unit length
	v.set(n.cross(u));                                     // make v =  n X u
	setModelViewMatrix();                                  // tell OpenGL 
}
void Camera:: pitch(GLdouble angle) { //pitch the camera through angle degrees
	GLdouble cs = cos(3.14159265 /180 * angle);
	GLdouble sn = sin(3.14159265 /180 * angle);
	Vector3 t(v); //remember old u
	v.set(cs*t.x + sn*n.x, cs*t.y + sn*n.y, cs*t.z + sn*n.z);
	n.set(-sn*t.x + cs*n.x, -sn*t.y + cs*n.y, -sn*t.z + cs*n.z);
	setModelViewMatrix();	
}
Esempio n. 10
0
void Camera:: roll(GLdouble angle) {  //roll the camera through angle degrees
	GLdouble cs = cos(3.14159265 /180 * angle);
	GLdouble sn = sin(3.14159265 /180 * angle);
	Vector3 t(u); //remember old u
	u.set(cs*t.x - sn*v.x, cs*t.y - sn*v.y, cs*t.z - sn*v.z);
	v.set(sn*t.x + cs*v.x, sn*t.y + cs*v.y, sn*t.z + cs*v.z);
	setModelViewMatrix();	
}
//<<<<<<<<<<<<<<<<<<<<<< slide >>>>>>>>>>>>>>>>>>>>>>.. 
void Camera :: slide(double du, double dv, double dn) 
{ // slide both eye and lookAt by amount du * u + dv * v + dn * n; 

	eye.x += du * u.x + dv * v.x + dn * n.x;
	eye.y += du * u.y + dv * v.y + dn * n.y;
	eye.z += du * u.z + dv * v.z + dn * n.z;
	setModelViewMatrix();

} 
Esempio n. 12
0
 // Generic camera (from REST) in meters
 void onCamera( const ::zeq::Event& event )
 {
     const auto& matrix = ::zeq::hbp::deserializeCamera( event );
     Matrix4f modelViewMatrix;
     modelViewMatrix.set( matrix.begin(), matrix.end(), false );
     auto cameraSettings = _config.getFrameData().getCameraSettings();
     cameraSettings->setModelViewMatrix( modelViewMatrix );
     _config.postRedraw();
 }
Esempio n. 13
0
void Camera::yaw(GLdouble alpha){

	n->scale(cos(alpha));
	u->scale(sin(alpha));
	n->plus(u);

	u = v->cross(n);
	setModelViewMatrix();
}
Esempio n. 14
0
void Camera::roll(GLdouble alpha){
	
	u->scale(cos(alpha));
	v->scale(sin(alpha));
	u->plus(v);

	v = n->cross(u);
	setModelViewMatrix();
}
Esempio n. 15
0
void Camera :: pitch(float angle)
{ // pitch the camera through angle degrees
	float cs = cos(3.14159265/180 * angle);
	float sn = sin(3.14159265/180 * angle);
	
	n->set(cs*n->x + sn*v->x, cs*n->y + sn*v->y, cs*n->z + sn*v->z);
	v->set(cs*v->x - sn*n->x, cs*v->y - sn*n->y, cs*v->z - sn*n->z);

	setModelViewMatrix();
}
Esempio n. 16
0
void Camera::pitch(GLdouble alpha){

	v->scale(cos(alpha));
	n->scale(sin(alpha));
	v->plus(n);

	n = u->cross(v);
	setModelViewMatrix();

}
Esempio n. 17
0
void Camara::cambiaPosicion(PV3D* ojo,PV3D* direccion,PV3D* arriba) {
    delete eye;
    delete look;
    delete up;
    delete u;
    delete v;
    delete n;
    setView(ojo, direccion, arriba);
    setModelViewMatrix();
}
Esempio n. 18
0
void GLCamera::slide(float du, float dv, float dn)
{
    //std::cout<<"u.x:"<<u.x<<std::endl;
    m_pos.x += du*u.x+dv*v.x+dn*n.x;
    m_pos.y += du*u.y +dv*v.y+dn*n.y;
    m_pos.z += du*u.z+dv*v.z+dn*n.z;
    m_target.x += du*u.x+dv*v.x+dn*n.x;
    m_target.y += du*u.y+dv*v.y+dn*n.y;
    m_target.z += du*u.z+dv*v.z+dn*n.z;
    setModelViewMatrix();
}
Esempio n. 19
0
void Camara::pitch(float angulo){
    GLfloat cs=cos(M_PI*angulo/(GLdouble)180);
    GLfloat sn=sin(M_PI*angulo/(GLdouble)180);
    PV3D* aux1 = new PV3D(n);
    PV3D* aux2 = new PV3D(v);
    n->setPV3D(cs*aux1->getX()+sn*aux2->getX(),cs*aux1->getY()+sn*aux2->getY(),cs*aux1->getZ()+sn*aux2->getZ(),1);
    v->setPV3D(-sn*aux1->getX()+cs*aux2->getX(),-sn*aux1->getY()+cs*aux2->getY(),-sn*aux1->getZ()+cs*aux2->getZ(),1);
    delete aux1;
    delete aux2;
    setModelViewMatrix();
}
Esempio n. 20
0
void Camera :: yaw(float angle)
{ // rotate the camera through angle degrees
	float cs = cos(3.14159265/180 * angle);
	float sn = sin(3.14159265/180 * angle);
	Vector3* t = new Vector3(u); 					// remember old u

	u->set(cs*u->x + sn*n->x, cs*u->y + sn*n->y, cs*u->z + sn*n->z);
	n->set(cs*n->x - sn*t->x, cs*n->y - sn*t->y, cs*n->z - sn*t->z);

	setModelViewMatrix();
}
Esempio n. 21
0
void Camara::setCameraCoordinateSystem() {
	//Obtiene el valor de los vectores u, v, n  
	//TO DO
	n = eye->clonar();
	n->restar(look);
	n->normalizar();
	u = up->productoVectorial(n);
	u->normalizar();
	v = n->productoVectorial(u);

	setModelViewMatrix();
}
//<<<<<<<<<<<<<<<<<<<< set >>>>>>>>>>>>>>>>>>> 
void Camera :: set(Point3 Eye, Point3 look, Vector3 up) 
{ // make u, v, n vectors 

	if( DEBUG )
		cout << "Calling set\n";

    eye.set(Eye); 
    n.set(eye.x - look.x, eye.y - look.y,eye.z - look.z); 
    u.set(up.cross(n)); 
    v.set(n.cross(u)); 
    u.normalize(); v.normalize(); n.normalize(); 
    setModelViewMatrix(); 
} 
Esempio n. 23
0
void Camera :: set(float eyex, float eyey, float eyez,
		float lookx, float looky, float lookz,
		float upx, float upy, float upz)
{	// create a modelview matrix and send it to OpenGL
	Point3 Eye(eyex, eyey, eyez);
	Point3 look(lookx, looky, lookz);
	Vector3* up = new Vector3(upx, upy, upz);
	eye.set(Eye); 						// store the given eye position
	n->set(eye.x - look.x, eye.y - look.y, eye.z - look.z);	// make n
	u->set( up->cross(n) ); 				// make u = up X n
	n->normalize(); u->normalize(); 			// make them unit length
	v->set(n->cross(u));  					// make v =  n X u
	setModelViewMatrix(); 					// tell OpenGL
}
Esempio n. 24
0
void Camara::yaw(float ang) {		
	GLfloat cs = cos(ang / 180.0f * 3.1415f);
	GLfloat sn = sin(ang / 180.0f * 3.1415f);
	u->setX(cs*u->getX() - sn*n->getX());
	u->setY(cs*u->getY() - sn*n->getY());
	u->setZ(cs*u->getZ() - sn*n->getZ());
	v->normalizar();
	n->setX(cs*n->getX() + sn*u->getX());
	n->setY(cs*n->getY() + sn*u->getY());
	n->setZ(cs*n->getZ() + sn*u->getZ());
	n->normalizar();

	setModelViewMatrix();
}
Esempio n. 25
0
GLCamera::GLCamera(const Vector3d &pos, const Vector3d &target, const Vector3d &up)
{
    m_pos = pos;
    m_target = target;
    m_up = up;
    n = Vector3d( pos.x-target.x, pos.y-target.y, pos.z-target.z);
    u = Vector3d(up.cross(n).x, up.cross(n).y, up.cross(n).z);
    v = Vector3d(n.cross(u).x,n.cross(u).y,n.cross(u).z);

    n.normalize();
    u.normalize();
    v.normalize();

    setModelViewMatrix();
}
Esempio n. 26
0
void GLCamera::roll(float angle)
{
    float cs=cos(angle*3.14159265/180);
    float sn=sin(angle*3.14159265/180);
    Vector3d t(u);
    Vector3d s(v);
    u.x = cs*t.x-sn*s.x;
    u.y = cs*t.y-sn*s.y;
    u.z = cs*t.z-sn*s.z;

    v.x = sn*t.x+cs*s.x;
    v.y = sn*t.y+cs*s.y;
    v.z = sn*t.z+cs*s.z;

    setModelViewMatrix();          //每次计算完坐标轴变化后调用此函数更新视点矩阵
}
Esempio n. 27
0
void Camara::roll(float ang) {
	//Rota la cámara tal como se explica en las transparencias
	//TO DO
	GLfloat cs = cos(ang / 180.0f * 3.1415f);
	GLfloat sn = sin(ang / 180.0f * 3.1415f);
	v->setX(cs*v->getX() - sn*u->getX());
	v->setY(cs*v->getY() - sn*u->getY());
	v->setZ(cs*v->getZ() - sn*u->getZ());
	v->normalizar();
	u->setX(cs*u->getX() + sn*v->getX());
	u->setY(cs*u->getY() + sn*v->getY());
	u->setZ(cs*u->getZ() + sn*v->getZ());
	u->normalizar();

    setModelViewMatrix();
}
Esempio n. 28
0
void GLCamera::yaw(float angle)
{
    float cs=cos(angle*3.14159265/180);
    float sn=sin(angle*3.14159265/180);
    Vector3d t(n);
    Vector3d s(u);

    n.x = cs*t.x-sn*s.x;
    n.y = cs*t.y-sn*s.y;
    n.z = cs*t.z-sn*s.z;

    u.x = sn*t.x+cs*s.x;
    u.y = sn*t.y+cs*s.y;
    u.z = sn*t.z+cs*s.z;

    setModelViewMatrix();
}
//<<<<<<<<<<<<<<<<<<<< set >>>>>>>>>>>>>>>>>>> 
void Camera :: set( float eyeX, float eyeY, float eyeZ, float lookX, float lookY, float lookZ, float upX, float upY, float upZ )
{
	if( DEBUG )
		cout << "Calling set\n";

	Point3 Eye = Point3( eyeX, eyeY, eyeZ );
	Point3 look = Point3( lookX, lookY, lookZ );

	Vector3 up = Vector3( upX, upY, upZ );

    eye.set(Eye); 
    n.set(eye.x - look.x, eye.y - look.y,eye.z - look.z); 
    u.set(up.cross(n)); 
    v.set(n.cross(u)); 
    u.normalize(); v.normalize(); n.normalize(); 
    setModelViewMatrix(); 	


}
Esempio n. 30
0
WindowPaintData::WindowPaintData(const WindowPaintData &other)
    : PaintData()
    , quads(other.quads)
    , shader(other.shader)
    , d(new WindowPaintDataPrivate())
{
    setXScale(other.xScale());
    setYScale(other.yScale());
    setZScale(other.zScale());
    translate(other.translation());
    setRotationOrigin(other.rotationOrigin());
    setRotationAxis(other.rotationAxis());
    setRotationAngle(other.rotationAngle());
    setOpacity(other.opacity());
    setSaturation(other.saturation());
    setBrightness(other.brightness());
    setScreen(other.screen());
    setCrossFadeProgress(other.crossFadeProgress());
    setProjectionMatrix(other.projectionMatrix());
    setModelViewMatrix(other.modelViewMatrix());
    d->screenProjectionMatrix = other.d->screenProjectionMatrix;
}