示例#1
0
bool ASkill::ConeTrace(AActor* actorToIgnore, const FVector& start, const FVector& dir, float coneHeight, TArray<AGameCharacter*>& hitsOut, ECollisionChannel traceChannel /* = ECC_Pawn */)
{
    TArray<FHitResult> sphereHits1, sphereHits2, sphereHits3, sphereHits4;
    FVector dp(0.f, 0.0f, 1.0f);

    FVector p1 = start + (dir * (0.045*coneHeight));
    SphereTrace(actorToIgnore, p1, p1 + dp, 0.045f*coneHeight, sphereHits1, traceChannel);

    FVector p2 = start + (dir * (0.17*coneHeight));
    SphereTrace(actorToIgnore, p2, p2 + dp, 0.08f*coneHeight, sphereHits2, traceChannel);

    FVector p3 = start + (dir * (0.395*coneHeight));
    SphereTrace(actorToIgnore, p3, p3 + dp, 0.145f*coneHeight, sphereHits3, traceChannel);

    FVector p4 = start + (dir * (0.77*coneHeight));
    SphereTrace(actorToIgnore, p4, p4 + dp, 0.23f*coneHeight, sphereHits4, traceChannel);

    sphereHits1.Append(sphereHits2);
    sphereHits1.Append(sphereHits3);
    sphereHits1.Append(sphereHits4);

    for (int32 i = 0; i < sphereHits1.Num(); i++)
    {
        AGameCharacter* mc = Cast<AGameCharacter>(sphereHits1[i].GetActor());
        if (mc)
            hitsOut.AddUnique(mc);
    }

    return true;
}
void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
  vec2 pixel = (gl_FragCoord.xy / iResolution.xy)*2.0-1.0;

  // compute ray origin and direction
  float asp = iResolution.x / iResolution.y;
  vec3 rd = normalize(vec3(asp*pixel.x, pixel.y, -4.0));
  vec3 ro = vec3(0.0, 0.0, 20.0);

  // vec2 mouse = iMouse.xy / iResolution.xy;
  float a=iGlobalTime*0.25;
  ro = rotateY(ro, a);
  rd = rotateY(rd, a);

  // Trace ray
  bool hit;

  // Number of steps
  int s;

  float t = SphereTrace(ro, rd, hit,s);
  vec3 pos=ro+t*rd;
  // Shade background
  vec3 rgb = background(rd);

  if (hit)
  {
    // Compute normal
    vec3 n = ObjectNormal(pos);

    // Shade object with light
    rgb = Shade(pos, n);
  }

  // Uncomment this line to shade image with false colors representing the number of steps
  //rgb = ShadeSteps(s);

  fragColor=vec4(rgb, 1.0);
}