+ const float ang = 45.0f * SG_PI / 180.0f;
+
+ // compute normals
+ list_of_spriteDef::iterator iSprite;
+ for( iSprite = list_spriteDef.begin() ; iSprite != list_spriteDef.end() ; iSprite++ ) {
+ sgVec3 normal;
+ spriteContainer *thisSpriteContainer = &list_spriteContainer[iSprite->box];
+ if( familly == CLFamilly_sc || familly == CLFamilly_cu || familly == CLFamilly_cb) {
+ sgSubVec3(normal, iSprite->pos, center);
+ } else {
+ sgSubVec3(normal, iSprite->pos, thisSpriteContainer->pos);
+ sgSubVec3(normal, thisSpriteContainer->center);
+ sgSubVec3(normal, cloudpos);
+ }
+ if( normal[0] == 0.0f && normal[1] == 0.0f && normal[2] == 0.0f )
+ sgSetVec3( normal, 0.0f, 1.0f, 0.0f );
+ sgNormaliseVec3(normal);
+ // use exotic lightning function, this will give more 'relief' to the clouds
+ // compute a normal for each vextex this will simulate a smooth shading for a round shape
+ sgVec3 polar, pt;
+ // I suspect this code to be bugged...
+ CartToPolar3d(normal, polar);
+ sgCopyVec3(iSprite->normal, normal);
+
+ // offset the normal vector by some angle for each vertex
+ sgSetVec3(pt, polar[0] - ang, polar[1] - ang, polar[2]);
+ PolarToCart3d(pt, iSprite->n0);
+ sgSetVec3(pt, polar[0] + ang, polar[1] - ang, polar[2]);
+ PolarToCart3d(pt, iSprite->n1);
+ sgSetVec3(pt, polar[0] + ang, polar[1] + ang, polar[2]);
+ PolarToCart3d(pt, iSprite->n2);
+ sgSetVec3(pt, polar[0] - ang, polar[1] + ang, polar[2]);
+ PolarToCart3d(pt, iSprite->n3);
+ }
+
+ // experimental : clouds are dissipating with time
+ if( familly == CLFamilly_cu ) {
+ startFade(true, 300.0f, 30.0f);
+ fadetimer = sg_random() * 300.0f;
+ }