//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void RigCaseToCaseCellMapperTools::rotateCellTopologicallyToMatchBaseCell(const cvf::Vec3d * baseCell, bool baseCellFaceNormalsIsOutwards, cvf::Vec3d * cell)
{
    int femDeepZFaceIdx = findMatchingPOSKFaceIdx(baseCell, baseCellFaceNormalsIsOutwards, cell);

    {
        cvf::Vec3d tmpFemCorners[8];
        tmpFemCorners[0] = cell[0];
        tmpFemCorners[1] = cell[1];
        tmpFemCorners[2] = cell[2];
        tmpFemCorners[3] = cell[3];
        tmpFemCorners[4] = cell[4];
        tmpFemCorners[5] = cell[5];
        tmpFemCorners[6] = cell[6];
        tmpFemCorners[7] = cell[7];

        int femShallowZFaceIdx = RigFemTypes::oppositeFace(HEX8, femDeepZFaceIdx);

        int faceNodeCount;
        const int*  localElmNodeIndicesForPOSKFace = RigFemTypes::localElmNodeIndicesForFace(HEX8, femDeepZFaceIdx, &faceNodeCount);
        const int*  localElmNodeIndicesForNEGKFace = RigFemTypes::localElmNodeIndicesForFace(HEX8, femShallowZFaceIdx, &faceNodeCount);

        cell[0] = tmpFemCorners[localElmNodeIndicesForNEGKFace[0]];
        cell[1] = tmpFemCorners[localElmNodeIndicesForNEGKFace[1]];
        cell[2] = tmpFemCorners[localElmNodeIndicesForNEGKFace[2]];
        cell[3] = tmpFemCorners[localElmNodeIndicesForNEGKFace[3]];
        cell[4] = tmpFemCorners[localElmNodeIndicesForPOSKFace[0]];
        cell[5] = tmpFemCorners[localElmNodeIndicesForPOSKFace[1]];
        cell[6] = tmpFemCorners[localElmNodeIndicesForPOSKFace[2]];
        cell[7] = tmpFemCorners[localElmNodeIndicesForPOSKFace[3]];
    }

    cvf::Vec3d* femDeepestQuad = &(cell[4]);
    cvf::Vec3d* femShallowQuad = &(cell[0]);

    // Now the top/bottom have opposite winding. To make the comparisons and index rotations simpler
    // flip the winding of the top or bottom face depending on whether the eclipse grid is inside-out

    if (baseCellFaceNormalsIsOutwards)
    {
        flipQuadWinding(femShallowQuad);
    }
    else
    {
        flipQuadWinding(femDeepestQuad);
    }

    // We now need to rotate the fem quads to be alligned with the ecl quads
    // Since the start point of the quad always is aligned with the opposite face-quad start
    // we can find the rotation for the top, and apply it to both top and bottom

    int femQuadStartIdx = quadVxClosestToXYOfPoint(baseCell[0], femShallowQuad);
    rotateQuad(femDeepestQuad, femQuadStartIdx);
    rotateQuad(femShallowQuad, femQuadStartIdx);

}
예제 #2
0
파일: render.cpp 프로젝트: tempbottle/kj2
/*! jesli widoczny to go narysuje
*/
void SpriteCmp::draw( Entity e , const ShapeDef& shapeDef)
{
  SpriteInfo * spriteInfo = 0;
  if(e.getId() == 0)
  {
    spriteInfo = &untexturedSprite;
  }else{
    spriteInfo = BaseType::get( e );
    if( ! spriteInfo )  return;
  }
  Render * r = game->getRender();

  if( spriteInfo->visible )
  {
    Vec2Quad shape;
    translateQuad( shapeDef.rect, shapeDef.pos, &shape );
    if(shapeDef.angle)
      rotateQuad(shape,shapeDef.angle,shapeDef.pos,&shape);
    r->drawAtlas( spriteInfo->tex,
                  spriteInfo->textureNumber, shape,
                  Render::CoordSpace_e( spriteInfo->coordSpace ),
                  spriteInfo->color,
                  shapeDef.depth );
  }
}
예제 #3
0
파일: render.cpp 프로젝트: tempbottle/kj2
/*! rysuje tylko widoczne
*/
void SpriteCmp::drawAll()
{
  Render * r = game->getRender();
  ShapeCmp * shapeCmp = game->getShapeCmp();

  FOR_ALL( records, it ) {
    SpriteInfo * scd = *it;
    ShapeDef * shapeDef = shapeCmp->getSure( scd->shape );
    if( scd->visible ) {

      Vec2Quad shape;
      //rotateQuad(shapeDef->rect,shapeDef->angle,shapeDef->pos,&shape );
      //translateQuad( shape, shapeDef->pos, &shape );
      translateQuad( shapeDef->rect, shapeDef->pos, &shape );
      if(shapeDef->angle)
        rotateQuad(shape,shapeDef->angle,shapeDef->pos,&shape);
      r->drawAtlas( scd->tex, scd->textureNumber, shape,
                    Render::CoordSpace_e( scd->coordSpace ), scd->color,
                    shapeDef->depth );
    }
  }//koniec for(records)