⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 debug.pas

📁 3D GameStudio 的Delphi开发包
💻 PAS
📖 第 1 页 / 共 2 页
字号:

  // create beam particle effect from Start postion to the Stop position
  effect_local(@GreenParticleLine,_VAR(1),Start,@AVec.x);
end;

procedure Debug_DrawLine_ToFront(Entity : PEntity; Dist : Var_);

// example: Debug_DrawLine_ToFront(ev.me,_VAR(125));

var AVec : TVector;
begin
  if Entity = Nil then Exit;

  vec_for_angle(@AVec.x,@Entity.pan);  // point vector in direction of angle
  vec_normalize(@AVec.x,Dist);         // scale vector by Dist keeping direction

  // create beam particle effect from Entity.x postion in direction
  // of the AVec.x vector
  effect_local(@RedParticleLine,_VAR(1),@Entity.x,@AVec.x);
end;

procedure Debug_C_Scan(Entity : PEntity; Angle : PAngle; Scan : PVector);

// example: Debug_C_Scan(ev.me,@ev.me.pan,_vec(5,5,125));

var AVec : TVector;
    NumRays,
    RayAngle,
    I,WorkPan : Integer;
    WorkAng,WorkAng2 : TAngle;
begin
  if Entity = Nil then Exit;

  // horizontal
  RayAngle := _INT(Scan.x);

  case RayAngle of
    0..179   : begin
                 NumRays  := 2;
                 RayAngle := RayAngle Div 2;
               end;

    180      : begin
                 NumRays  := 3;
                 RayAngle := 90;
               end;

    181..359 : begin
                 NumRays  := 3;
                 RayAngle := RayAngle Div 2;
               end;
    else
    begin
      NumRays  := 4;
      RayAngle := 90;
    end;
  end;

  for I := 1 to NumRays do
  begin
    case I of
      1 : WorkPan  := RayAngle;
      2 : WorkPan  := RayAngle * -1;
      3 : WorkPan  := 0;
      4 : WorkPan  := 180;
     else WorkPan  := 0;
    end;

    WorkAng2.pan  := _VAR(WorkPan);
    WorkAng2.tilt := 0;
    WorkAng2.roll := 0;

    WorkAng.pan  := Angle.pan;
    WorkAng.tilt := Angle.tilt;
    WorkAng.roll := Angle.roll;

    ang_rotate(@WorkAng.pan,@WorkAng2.pan);
    //ang_add(@WorkAng.pan,@WorkAng2.pan);


    vec_for_angle(@AVec.x,@WorkAng.pan);  // point vector in direction of angle
    vec_normalize(@AVec.x,Scan.z);        // scale vector by Dist keeping direction

    // create beam particle effect from Entity.x postion in direction
    // of the AVec.x vector
    effect_local(@RedParticleLine,_VAR(1),@Entity.x,@AVec.x);
  end;


  // vertical
  RayAngle := _INT(Scan.y);

  case RayAngle of
    0..179   : begin
                 NumRays  := 2;
                 RayAngle := RayAngle Div 2;
               end;

    180      : begin
                 NumRays  := 3;
                 RayAngle := 90;
               end;

    181..359 : begin
                 NumRays  := 3;
                 RayAngle := RayAngle Div 2;
               end;
    else
    begin
      NumRays  := 4;
      RayAngle := 90;
    end;
  end;

  for I := 1 to NumRays do
  begin
    case I of
      1 : WorkPan  := RayAngle;
      2 : WorkPan  := RayAngle * -1;
      3 : WorkPan  := 0;
      4 : WorkPan  := 180;
     else WorkPan  := 0; 
    end;

    WorkAng2.pan  := 0;
    WorkAng2.tilt := _VAR(WorkPan);
    WorkAng2.roll := 0;

    WorkAng.pan  := Angle.pan;
    WorkAng.tilt := Angle.tilt;
    WorkAng.roll := Angle.roll;

    ang_rotate(@WorkAng.pan,@WorkAng2.pan);
    //ang_add(@WorkAng.pan,@WorkAng2.pan);


    vec_for_angle(@AVec.x,@WorkAng.pan);  // point vector in direction of angle
    vec_normalize(@AVec.x,Scan.z);        // scale vector by Dist keeping direction

    // create beam particle effect from Entity.x postion in direction
    // of the AVec.x vector
    effect_local(@BlueParticleLine,_VAR(1),@Entity.x,@AVec.x);
  end;
end;

procedure Debug_DrawBoundBox(Entity : PEntity);

// example: Debug_DrawBoundBox(ev.me);

var BotVec1,
    BotVec2,
    BotVec3,
    BotVec4,
    TopVec1,
    TopVec2,
    TopVec3,
    TopVec4 : TVector;
begin
  if Entity = Nil then Exit;

  // bottom 1st point
  vec_set(@BotVec1.x,@Entity.x);
  Inc(BotVec1.x,Entity.bmin.x);
  Inc(BotVec1.y,Entity.bmin.y);
  Inc(BotVec1.z,Entity.bmin.z);

  // bottom 2nd point
  vec_set(@BotVec2.x,@Entity.x);
  Dec(BotVec2.x,Entity.bmin.x);
  Inc(BotVec2.y,Entity.bmin.y);
  Inc(BotVec2.z,Entity.bmin.z);

  // bottom 3rd point
  vec_set(@BotVec3.x,@Entity.x);
  Inc(BotVec3.x,Entity.bmin.x);
  Dec(BotVec3.y,Entity.bmin.y);
  Inc(BotVec3.z,Entity.bmin.z);

  // bottom 4th point
  vec_set(@BotVec4.x,@Entity.x);
  Dec(BotVec4.x,Entity.bmin.x);
  Dec(BotVec4.y,Entity.bmin.y);
  Inc(BotVec4.z,Entity.bmin.z);

  // draw bottom
  Debug_DrawBlueLine(@BotVec1.x,@BotVec2.x);
  Debug_DrawBlueLine(@BotVec2.x,@BotVec4.x);
  Debug_DrawBlueLine(@BotVec3.x,@BotVec1.x);
  Debug_DrawBlueLine(@BotVec4.x,@BotVec3.x);

  // top 1st point
  vec_set(@TopVec1.x,@Entity.x);
  Inc(TopVec1.x,Entity.bmax.x);
  Inc(TopVec1.y,Entity.bmax.y);
  Inc(TopVec1.z,Entity.bmax.z);

  // top 2nd point
  vec_set(@TopVec2.x,@Entity.x);
  Dec(TopVec2.x,Entity.bmax.x);
  Inc(TopVec2.y,Entity.bmax.y);
  Inc(TopVec2.z,Entity.bmax.z);

  // top 3rd point
  vec_set(@TopVec3.x,@Entity.x);
  Inc(TopVec3.x,Entity.bmax.x);
  Dec(TopVec3.y,Entity.bmax.y);
  Inc(TopVec3.z,Entity.bmax.z);

  // top 4th point
  vec_set(@TopVec4.x,@Entity.x);
  Dec(TopVec4.x,Entity.bmax.x);
  Dec(TopVec4.y,Entity.bmax.y);
  Inc(TopVec4.z,Entity.bmax.z);

  // draw top
  Debug_DrawRedLine(@TopVec1.x,@TopVec2.x);
  Debug_DrawRedLine(@TopVec2.x,@TopVec4.x);
  Debug_DrawRedLine(@TopVec3.x,@TopVec1.x);
  Debug_DrawRedLine(@TopVec4.x,@TopVec3.x);

  // draw sides
  Debug_DrawGreenLine(@BotVec1.x,@TopVec4.x);
  Debug_DrawGreenLine(@BotVec2.x,@TopVec3.x);
  Debug_DrawGreenLine(@BotVec3.x,@TopVec2.x);
  Debug_DrawGreenLine(@BotVec4.x,@TopVec1.x);
end;

procedure Debug_DrawTriggerRange(Entity : PEntity);

// example: Debug_DrawTriggerRange(ev.me);

var BotVec1,
    BotVec2,
    BotVec3,
    BotVec4,
    TopVec1,
    TopVec2,
    TopVec3,
    TopVec4 : TVector;
begin
  if Entity = Nil then Exit;

  // bottom 1st point of bounding box
  vec_set(@BotVec1.x,@Entity.x);
  Inc(BotVec1.x,Entity.bmin.x);
  Inc(BotVec1.y,Entity.bmin.y);
  Inc(BotVec1.z,Entity.bmin.z);

  // bottom 1st point
  //vec_set(@BotVec1.x,@Entity.x);
  Dec(BotVec1.x,Entity.trigger_range);
  Dec(BotVec1.y,Entity.trigger_range);
  Dec(BotVec1.z,Entity.trigger_range);

  // bottom 2nd point of bounding box
  vec_set(@BotVec2.x,@Entity.x);
  Dec(BotVec2.x,Entity.bmin.x);
  Inc(BotVec2.y,Entity.bmin.y);
  Inc(BotVec2.z,Entity.bmin.z);

  // bottom 2nd point
  //vec_set(@BotVec2.x,@Entity.x);
  Inc(BotVec2.x,Entity.trigger_range);
  Dec(BotVec2.y,Entity.trigger_range);
  Dec(BotVec2.z,Entity.trigger_range);

  // bottom 3rd point of bounding box
  vec_set(@BotVec3.x,@Entity.x);
  Inc(BotVec3.x,Entity.bmin.x);
  Dec(BotVec3.y,Entity.bmin.y);
  Inc(BotVec3.z,Entity.bmin.z);

  // bottom 3rd point
  //vec_set(@BotVec3.x,@Entity.x);
  Dec(BotVec3.x,Entity.trigger_range);
  Inc(BotVec3.y,Entity.trigger_range);
  Dec(BotVec3.z,Entity.trigger_range);

  // bottom 4th point of bounding box
  vec_set(@BotVec4.x,@Entity.x);
  Dec(BotVec4.x,Entity.bmin.x);
  Dec(BotVec4.y,Entity.bmin.y);
  Inc(BotVec4.z,Entity.bmin.z);

  // bottom 4th point
  //vec_set(@BotVec4.x,@Entity.x);
  Inc(BotVec4.x,Entity.trigger_range);
  Inc(BotVec4.y,Entity.trigger_range);
  Dec(BotVec4.z,Entity.trigger_range);

  // draw bottom
  Debug_DrawBlueLine(@BotVec1.x,@BotVec2.x);
  Debug_DrawBlueLine(@BotVec2.x,@BotVec4.x);
  Debug_DrawBlueLine(@BotVec3.x,@BotVec1.x);
  Debug_DrawBlueLine(@BotVec4.x,@BotVec3.x);

  // top 1st point of bounding box
  vec_set(@TopVec1.x,@Entity.x);
  Inc(TopVec1.x,Entity.bmax.x);
  Inc(TopVec1.y,Entity.bmax.y);
  Inc(TopVec1.z,Entity.bmax.z);

  // top 1st point
  //vec_set(@TopVec1.x,@Entity.x);
  Inc(TopVec1.x,Entity.trigger_range);
  Inc(TopVec1.y,Entity.trigger_range);
  Inc(TopVec1.z,Entity.trigger_range);

  // top 2nd point of bounding box
  vec_set(@TopVec2.x,@Entity.x);
  Dec(TopVec2.x,Entity.bmax.x);
  Inc(TopVec2.y,Entity.bmax.y);
  Inc(TopVec2.z,Entity.bmax.z);

  // top 2nd point
//  vec_set(@TopVec2.x,@Entity.x);
  Dec(TopVec2.x,Entity.trigger_range);
  Inc(TopVec2.y,Entity.trigger_range);
  Inc(TopVec2.z,Entity.trigger_range);

  // top 3rd point of bounding box
  vec_set(@TopVec3.x,@Entity.x);
  Inc(TopVec3.x,Entity.bmax.x);
  Dec(TopVec3.y,Entity.bmax.y);
  Inc(TopVec3.z,Entity.bmax.z);

  // top 3rd point
  //vec_set(@TopVec3.x,@Entity.x);
  Inc(TopVec3.x,Entity.trigger_range);
  Dec(TopVec3.y,Entity.trigger_range);
  Inc(TopVec3.z,Entity.trigger_range);

  // top 4th point of bounding box
  vec_set(@TopVec4.x,@Entity.x);
  Dec(TopVec4.x,Entity.bmax.x);
  Dec(TopVec4.y,Entity.bmax.y);
  Inc(TopVec4.z,Entity.bmax.z);

  // top 4th point
  //vec_set(@TopVec4.x,@Entity.x);
  Dec(TopVec4.x,Entity.trigger_range);
  Dec(TopVec4.y,Entity.trigger_range);
  Inc(TopVec4.z,Entity.trigger_range);

  // draw top
  Debug_DrawRedLine(@TopVec1.x,@TopVec2.x);
  Debug_DrawRedLine(@TopVec2.x,@TopVec4.x);
  Debug_DrawRedLine(@TopVec3.x,@TopVec1.x);
  Debug_DrawRedLine(@TopVec4.x,@TopVec3.x);

  // draw bottom to top connection
  Debug_DrawGreenLine(@BotVec1.x,@TopVec4.x);
  Debug_DrawGreenLine(@BotVec2.x,@TopVec3.x);
  Debug_DrawGreenLine(@BotVec3.x,@TopVec2.x);
  Debug_DrawGreenLine(@BotVec4.x,@TopVec1.x);

  // draw side 1
//  Debug_DrawBlueLine(@BotVec2.x,@TopVec4.x);
//  Debug_DrawBlueLine(@BotVec1.x,@TopVec3.x);
  // draw side 2
//  Debug_DrawBlueLine(@BotVec3.x,@TopVec4.x);
//  Debug_DrawBlueLine(@BotVec1.x,@TopVec2.x);
  // draw side 3
//  Debug_DrawBlueLine(@BotVec4.x,@TopVec2.x);
//  Debug_DrawBlueLine(@BotVec3.x,@TopVec1.x);
  // draw side 4
//  Debug_DrawBlueLine(@BotVec4.x,@TopVec3.x);
//  Debug_DrawBlueLine(@BotVec2.x,@TopVec1.x);
end;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -