Raycastintersect

gaita
2010-05-28
2013-03-15
  • gaita
    gaita
    2010-05-28

    Hi

    I'm trying to use ray castintersect to send it to any direction I want, but it doesent seem to work
    i using this
    example:

    Var
      raystart,
      rayvector,
      ipoint: TVector;
    begin
      raystart  := VectorMake(Object.Position.AsVector);
      rayvector := VectorMake(X, Y, Z);
      if ObjectA.RayCastIntersect(raystart, rayvector, @ipoint)
      then -> Create an Object at ipoint position

    But it always result false and I doesnt work, how can I use this to shoot it to any direction I want?

    thks

     
  • Kjow
    Kjow
    2010-05-29

    Try this:

    var
      rayStart, rayVector, iPoint, iNormal: TVector;
    Begin
      SetVector(rayStart, GLCamera.AbsolutePosition);
      SetVector(rayVector, GLViewerScena.Buffer.ScreenToVector(AffineVectorMake(X,Y,Z)));
      NormalizeVector(rayVector);
      if Freeorm.RayCastIntersect(rayStart, rayVector, @iPoint, @iNormal) then
        begin 
        end;
    end;