/*! * Defines a perspective projection based on \a fieldOfView, \a aspectRatio, \a * nearPlane, \a farPlane. */ void QCameraLens::setPerspectiveProjection(float fieldOfView, float aspectRatio, float nearPlane, float farPlane) { Q_D(QCameraLens); bool block = blockNotifications(true); setFieldOfView(fieldOfView); setAspectRatio(aspectRatio); setNearPlane(nearPlane); setFarPlane(farPlane); setProjectionType(PerspectiveProjection); blockNotifications(block); d->updateProjectionMatrix(); }
/*! * Defines an orthographic projection based on \a left, \a right, \a bottom, \a * top, \a nearPlane, \a farPlane. */ void QCameraLens::setFrustumProjection(float left, float right, float bottom, float top, float nearPlane, float farPlane) { Q_D(QCameraLens); bool block = blockNotifications(true); setLeft(left); setRight(right); setBottom(bottom); setTop(top); setNearPlane(nearPlane); setFarPlane(farPlane); setProjectionType(FrustumProjection); blockNotifications(block); d->updateProjectionMatrix(); }
void PerspectiveCamera::load(const QString &filename) { FILE *fp=fopen(filename.toStdString().c_str(),"rb"); float sfov=0; float sfarPlane=0; float snearPlane=0; GGL::Point3f sfrom; GGL::Point3f sto; GGL::Point3f sup; fread(&sfov,sizeof(float),1,fp); qDebug("fov:%f",sfov); fread(&sfarPlane,sizeof(float),1,fp); qDebug("far plane:%f",sfarPlane); fread(&snearPlane,sizeof(float),1,fp); qDebug("near plane:%f",snearPlane); float vsfrom[3]; fread(vsfrom,sizeof(float),3,fp); qDebug("from:%f,%f,%f",vsfrom[0],vsfrom[1],vsfrom[2]); float vsto[3]; fread(vsto,sizeof(float),3,fp); qDebug("to:%f,%f,%f",vsto[0],vsto[1],vsto[2]); float vsup[3]; fread(vsup,sizeof(float),3,fp); qDebug("up:%f,%f,%f",vsup[0],vsup[1],vsup[2]); fclose(fp); setFov(sfov); setFarPlane(sfarPlane); setNearPlane(snearPlane); setFrom(GGL::Point3f(vsfrom[0],vsfrom[1],vsfrom[2])); setTo(GGL::Point3f(vsto[0],vsto[1],vsto[2])); setUp(GGL::Point3f(vsup[0],vsup[1],vsup[2])); }