void TransformState::setMinPitch(double minPitch) { if (minPitch <= getMaxPitch()) { min_pitch = minPitch; } }
bool ccGBLSensor::applyViewport(ccGenericGLDisplay* win/*=0*/) { if (!win) { win = getDisplay(); if (!win) { ccLog::Warning("[ccGBLSensor::applyViewport] No associated display!"); return false; } } ccIndexedTransformation trans; if (!getActiveAbsoluteTransformation(trans)) { return false; } //scanner main directions CCVector3d sensorX(trans.data()[0],trans.data()[1],trans.data()[2]); CCVector3d sensorY(trans.data()[4],trans.data()[5],trans.data()[6]); CCVector3d sensorZ(trans.data()[8],trans.data()[9],trans.data()[10]); switch(getRotationOrder()) { case ccGBLSensor::YAW_THEN_PITCH: { double theta = (getMinYaw() + getMaxYaw())/2; ccGLMatrixd rotz; rotz.initFromParameters(theta,sensorZ,CCVector3d(0,0,0)); rotz.applyRotation(sensorX); rotz.applyRotation(sensorY); double phi = 0; //(getMinPitch() + getMaxPitch())/2; ccGLMatrixd roty; roty.initFromParameters(-phi,sensorY,CCVector3d(0,0,0)); //theta = 0 corresponds to the upward vertical direction! roty.applyRotation(sensorX); roty.applyRotation(sensorZ); break; } case ccGBLSensor::PITCH_THEN_YAW: { double phi = (getMinPitch() + getMaxPitch())/2; ccGLMatrixd roty; roty.initFromParameters(-phi,sensorY,CCVector3d(0,0,0)); //theta = 0 corresponds to the upward vertical direction! roty.applyRotation(sensorX); roty.applyRotation(sensorZ); double theta = (getMinYaw() + getMaxYaw())/2; ccGLMatrixd rotz; rotz.initFromParameters(theta,sensorZ,CCVector3d(0,0,0)); rotz.applyRotation(sensorX); rotz.applyRotation(sensorY); break; } default: assert(false); break; } //center camera on sensor CCVector3d sensorCenterd = CCVector3d::fromArray(trans.getTranslation()); ccGLMatrixd viewMat = ccGLMatrixd::FromViewDirAndUpDir(sensorX,sensorZ); viewMat.invert(); viewMat.setTranslation(sensorCenterd); //TODO: can we set the right FOV? win->setupProjectiveViewport(viewMat,0,1.0f,true,true); return true; }