Ejemplo n.º 1
0
 void Storage::fixNormal (osg::Vec3f& normal, int cellX, int cellY, int col, int row)
 {
     while (col >= ESM::Land::LAND_SIZE-1)
     {
         ++cellY;
         col -= ESM::Land::LAND_SIZE-1;
     }
     while (row >= ESM::Land::LAND_SIZE-1)
     {
         ++cellX;
         row -= ESM::Land::LAND_SIZE-1;
     }
     while (col < 0)
     {
         --cellY;
         col += ESM::Land::LAND_SIZE-1;
     }
     while (row < 0)
     {
         --cellX;
         row += ESM::Land::LAND_SIZE-1;
     }
     ESM::Land* land = getLand(cellX, cellY);
     if (land && land->mDataTypes&ESM::Land::DATA_VNML)
     {
         normal.x() = land->mLandData->mNormals[col*ESM::Land::LAND_SIZE*3+row*3];
         normal.y() = land->mLandData->mNormals[col*ESM::Land::LAND_SIZE*3+row*3+1];
         normal.z() = land->mLandData->mNormals[col*ESM::Land::LAND_SIZE*3+row*3+2];
         normal.normalize();
     }
     else
         normal = osg::Vec3f(0,0,1);
 }
Ejemplo n.º 2
0
 void Storage::averageNormal(osg::Vec3f &normal, int cellX, int cellY, int col, int row)
 {
     osg::Vec3f n1,n2,n3,n4;
     fixNormal(n1, cellX, cellY, col+1, row);
     fixNormal(n2, cellX, cellY, col-1, row);
     fixNormal(n3, cellX, cellY, col, row+1);
     fixNormal(n4, cellX, cellY, col, row-1);
     normal = (n1+n2+n3+n4);
     normal.normalize();
 }