Example #1
0
void Warp_Normal (VECTOR TNorm, VECTOR ENorm, TPATTERN *TPat, int DontScaleBumps)
{
   WARP *Warp=TPat->Warps;
   TRANS *Tr;

   if(!DontScaleBumps)
      VNormalize(TNorm,ENorm);
   else
      Assign_Vector(TNorm,ENorm);

   while(Warp != NULL)
   {
      switch(Warp->Warp_Type)
      {
        default:
        case NO_WARP:
          break;
        case TRANSFORM_WARP:
          Tr=(TRANS *)Warp;
          MInvTransNormal(TNorm, TNorm, &(Tr->Trans));
          break;
        /*
        default:
          Error("Warp type %d not yet implemented",Warp->Warp_Type);
        */
      }
      Warp=Warp->Next_Warp;
   }

   if(!DontScaleBumps)
      VNormalizeEq(TNorm);
}
Example #2
0
void Compute_Plane_Min_Max(PLANE *Plane, VECTOR Min, VECTOR  Max)
{
  DBL d;
  VECTOR P, N;

  if (Plane->Trans == NULL)
  {
    Assign_Vector(N, Plane->Normal_Vector);

    d = -Plane->Distance;
  }
  else
  {
    MInvTransNormal(N, Plane->Normal_Vector, Plane->Trans);

    MInvTransPoint(P, N, Plane->Trans);

    d = -Plane->Distance - P[X] * N[X] - P[Y] * N[Y] - P[Z] * N[Z] + 1.0;
  }

  Min[X] = Min[Y] = Min[Z] = -BOUND_HUGE/2;
  Max[X] = Max[Y] = Max[Z] =  BOUND_HUGE/2;

  /* y-z-plane */

  if (fabs(1.0 - fabs(N[X])) < EPSILON)
  {
    if (N[X] > 0.0)
    {
      Max[X] = d;
    }
    else
    {
      Min[X] = -d;
    }
  }

  /* x-z-plane */

  if (fabs(1.0 - fabs(N[Y])) < EPSILON)
  {
    if (N[Y] > 0.0)
    {
      Max[Y] = d;
    }
    else
    {
      Min[Y] = -d;
    }
  }

  /* x-y-plane */

  if (fabs(1.0 - fabs(N[Z])) < EPSILON)
  {
    if (N[Z] > 0.0)
    {
      Max[Z] = d;
    }
    else
    {
      Min[Z] = -d;
    }
  }
}
Example #3
0
bool TransformWarp::WarpNormal(Vector3d& TNorm) const
{
    MInvTransNormal(TNorm, TNorm, &Trans);
    return true;
}