void Camera::calcInverseModelView() const { if( ! mModelViewCached ) calcModelView(); mInverseModelViewMatrix = mModelViewMatrix.affineInverted(); mInverseModelViewCached = true; }
void Camera::calcMatrices() const { if( ! mModelViewCached ) calcModelView(); if( ! mProjectionCached ) calcProjection(); // note: calculation of the inverse modelview matrices is postponed until actually requested //if( ! mInverseModelViewCached ) calcInverseModelView(); }
void DSLightChunk::activate(DrawEnv *drawEnv, UInt32 index) { glErr("dslight:activate:precheck"); Matrix matMV; calcModelView(drawEnv, matMV); glPushMatrix(); glLoadMatrixf(matMV.getValues()); glLightfv( GL_LIGHT0 + index, GL_DIFFUSE, _sfDiffuse.getValue().getValuesRGBA()); glLightfv( GL_LIGHT0 + index, GL_AMBIENT, _sfAmbient.getValue().getValuesRGBA()); glLightfv( GL_LIGHT0 + index, GL_SPECULAR, _sfSpecular.getValue().getValuesRGBA()); glLightfv( GL_LIGHT0 + index, GL_POSITION, _sfPosition.getValue().getValues()); glLightf ( GL_LIGHT0 + index, GL_CONSTANT_ATTENUATION, _sfConstantAttenuation.getValue()); glLightf ( GL_LIGHT0 + index, GL_LINEAR_ATTENUATION, _sfLinearAttenuation.getValue()); glLightf ( GL_LIGHT0 + index, GL_QUADRATIC_ATTENUATION, _sfQuadraticAttenuation.getValue()); glLightf( GL_LIGHT0 + index, GL_SPOT_CUTOFF, _sfCutoff.getValue()); if(_sfCutoff.getValue() < 180.f) { glLightfv( GL_LIGHT0 + index, GL_SPOT_DIRECTION, _sfDirection.getValue().getValues()); glLightf( GL_LIGHT0 + index, GL_SPOT_EXPONENT, _sfExponent.getValue()); } glEnable(GL_LIGHT0 + index); glPopMatrix(); glErr("dslight:activate:postcheck"); }
void CameraStereo::calcInverseModelView() const { if( ! mModelViewCached ) calcModelView(); mInverseModelViewMatrix = mModelViewMatrix.affineInverted(); mInverseModelViewMatrixLeft = mModelViewMatrixLeft.affineInverted(); mInverseModelViewMatrixRight = mModelViewMatrixRight.affineInverted(); mInverseModelViewCached = true; }
const Matrix44f& CameraStereo::getModelViewMatrix() const { if( ! mModelViewCached ) calcModelView(); if( ! mIsStereo ) return mModelViewMatrix; else if( mIsLeft ) return mModelViewMatrixLeft; else return mModelViewMatrixRight; }
void DSLightChunk::changeFrom(DrawEnv *drawEnv, StateChunk *old, UInt32 index) { glErr("dslight:change:precheck"); const DSLightChunk *oldChunk = dynamic_cast<const DSLightChunk *>(old); // change from me to me? // this assumes I haven't changed in the meantime. is that a valid // assumption? if(oldChunk == this) return; Matrix matMV; calcModelView(drawEnv, matMV); glPushMatrix(); glLoadMatrixf(matMV.getValues()); // it could theoretically be more efficient to turn the light off before // changing its parameters, have to try that sometime glLightfv( GL_LIGHT0 + index, GL_DIFFUSE, _sfDiffuse.getValue().getValuesRGBA()); glLightfv( GL_LIGHT0 + index, GL_AMBIENT, _sfAmbient.getValue().getValuesRGBA()); glLightfv( GL_LIGHT0 + index, GL_SPECULAR, _sfSpecular.getValue().getValuesRGBA()); glLightfv( GL_LIGHT0 + index, GL_POSITION, _sfPosition.getValue().getValues()); glLightf ( GL_LIGHT0 + index, GL_CONSTANT_ATTENUATION, _sfConstantAttenuation.getValue()); glLightf ( GL_LIGHT0 + index, GL_LINEAR_ATTENUATION, _sfLinearAttenuation.getValue()); glLightf ( GL_LIGHT0 + index, GL_QUADRATIC_ATTENUATION, _sfQuadraticAttenuation.getValue()); glLightf( GL_LIGHT0 + index, GL_SPOT_CUTOFF, _sfCutoff.getValue()); if(_sfCutoff.getValue() < 180.f) { glLightfv( GL_LIGHT0 + index, GL_SPOT_DIRECTION, _sfDirection.getValue().getValues()); glLightf( GL_LIGHT0 + index, GL_SPOT_EXPONENT, _sfExponent.getValue()); } glPopMatrix(); glErr("dslight:change:postcheck"); }