/
perso2 *-----
*/
-void SGShadowVolume::ShadowCaster::computeShadows(sgMat4 rotation, sgMat4 rotation_translation) {
+void SGShadowVolume::ShadowCaster::computeShadows(sgMat4 rotation, sgMat4 rotation_translation,
+ OccluderType occluder_type) {
// check the select and range ssgSelector node
// object can't cast shadow if it is not visible
if( first_select && ! isSelected( first_select) )
return;
- sgMat4 transform ;
- sgMat4 invTransform;
// get the transformations : this comes from animation code for example
// or static transf
+ sgMat4 transf;
+ sgVec3 lightPos;
+ int deltaFrame = occluder_type == SGShadowVolume::occluderTypeAircraft ? 0 : 9;
+ if( states->frameNumber - frameNumber > deltaFrame) {
+ sgMat4 transform ;
+ sgMat4 invTransform;
getNetTransform( (ssgBranch *) geometry_leaf, transform );
- sgMat4 transf;
- sgCopyMat4( transf, transform );
- sgPostMultMat4( transf, rotation_translation );
+ sgCopyMat4( last_transform, transform );
sgPostMultMat4( transform, rotation );
sgTransposeNegateMat4 ( invTransform, transform );
- glLoadMatrixf ( (float *) states->CameraViewM ) ;
- glMultMatrixf( (float *) transf );
-
- sgVec3 lightPos;
sgCopyVec3( lightPos, states->sunPos );
sgXformPnt3( lightPos, invTransform );
// if the geometry has rotated/moved enought then
// we need to recompute the silhouette
// but this computation does not need to be done each frame
- if( (deltaPos > 0.0) && ( states->frameNumber - frameNumber > 4)) {
+ if( deltaPos > 0.0 ) {
CalculateSilhouetteEdges( lightPos );
sgCopyVec3( last_lightpos, lightPosNorm );
frameNumber = states->frameNumber ;
statSilhouette ++;
}
+ }
+ sgCopyMat4( transf, last_transform );
+ sgPostMultMat4( transf, rotation_translation );
+ glLoadMatrixf ( (float *) states->CameraViewM ) ;
+ glMultMatrixf( (float *) transf );
if( states->shadowsDebug_enabled )
{
ShadowCaster_list::iterator iShadowCaster;
for(iShadowCaster = parts.begin() ; iShadowCaster != parts.end() ; iShadowCaster ++ ) {
- (*iShadowCaster)->computeShadows(rotation, rotation_translation);
+ (*iShadowCaster)->computeShadows(rotation, rotation_translation, occluder_type);
}
}
}
ssgBranch *lib_object;
ssgBranch *first_select;
sgVec3 last_lightpos;
+ sgMat4 last_transform;
int frameNumber;
int *indices;
void SetConnectivity();
void CalculateSilhouetteEdges(sgVec3 lightPosition);
void DrawInfiniteShadowVolume(sgVec3 lightPosition, bool drawCaps);
- void computeShadows(sgMat4 rotation, sgMat4 rotation_translation);
+ void computeShadows(sgMat4 rotation, sgMat4 rotation_translation, OccluderType occluder_type);
void getNetTransform ( ssgBranch * branch, sgMat4 xform );
bool isSelected ( ssgBranch * branch );