unit uBody;

interface

uses uGlobal;

function model_body(Params: array of variant): variant; stdcall;

implementation

function model_body(Params: array of variant): variant; stdcall;
var
  P, R, S: array of Double;

  //Base
  BaseRoot, Base, CameraTarget, SmokeSource: integer;
begin
  SetLength(P, 3);
  SetLength(R, 3);
  SetLength(S, 3);
  P[0]:=0;  P[1]:=0;  P[2]:=0;
  R[0]:=0;  R[1]:=0;  R[2]:=0;
  S[0]:=1;  S[1]:=1;  S[2]:=1;

  //Init POA-Animated Object
  Result:=call('POAAdd',[]);
  call('POAFrames',[Result, 9]);

  P[0]:=0;  P[1]:=2;  P[2]:=0;
  BaseRoot:=call('POAObjectAdd',[Result, otRoot, P,R,S]);
  if length(Params)>0 then call('glObjectParent', [call('poaObjectID', [Result, BaseRoot]), call('poaObjectID', [Result, call('poaObjectID', [Params[0], 0])])]);

  P[0]:=0;  P[1]:=18;  P[2]:=0;
  CameraTarget:=call('POAObjectAdd',[Result, otRoot, P,R,S]);
  if length(Params)>0 then call('glObjectParent', [call('poaObjectID', [Result, CameraTarget]), call('poaObjectID', [Result, call('poaObjectID', [Params[0], 0])])]);

  P[0]:=7.2;  P[1]:=10;  P[2]:=3;
  SmokeSource:=call('POAObjectAdd',[Result, otRoot, P,R,S]);
  if length(Params)>0 then call('glObjectParent', [call('poaObjectID', [Result, SmokeSource]), call('poaObjectID', [Result, call('poaObjectID', [Params[0], 0])])]);
  call('pfxAssign',['smoke', call('poaObjectID', [Result, SmokeSource])]);
  call('pfxInterval', [call('poaObjectID', [Result, SmokeSource]),0.01]);

  //=============
  P[0]:=0;  P[1]:=0;  P[2]:=0;
  R[0]:=0;  R[1]:=90;  R[2]:=90;
  S[0]:=0.1;  S[1]:=0.1;  S[2]:=0.08;
  Base:=call('POAObjectAdd',[Result, otModel, P,R,S, 'data\models\body.3ds']);
  call('glObjectParent', [call('poaObjectID', [Result, Base]), call('poaObjectID', [Result, BaseRoot])]);

  call('POAReset',[Result]);

  //===============
  P[0]:=0;  P[1]:=0;  P[2]:=0;
  R[0]:=0;  R[1]:=0;  R[2]:=0;
  S[0]:=1;  S[1]:=1;  S[2]:=1;

  P[0]:=0;  P[1]:=0;  P[2]:=0.2;
  R[0]:=0;  R[1]:=0;  R[2]:=-2;
  call('poaTransformAdd', [Result, 1, BaseRoot, P,R,S]);
  P[0]:=0;  P[1]:=0;  P[2]:=-0.1;
  R[0]:=0;  R[1]:=0;  R[2]:=1;
  call('poaTransformAdd', [Result, 2, BaseRoot, P,R,S]);
  P[0]:=0;  P[1]:=0;  P[2]:=-0.2;
  R[0]:=0;  R[1]:=0;  R[2]:=2;
  call('poaTransformAdd', [Result, 3, BaseRoot, P,R,S]);
  P[0]:=0;  P[1]:=0;  P[2]:=0.1;
  R[0]:=0;  R[1]:=0;  R[2]:=-1;
  call('poaTransformAdd', [Result, 4, BaseRoot, P,R,S]);
                                         {
  R[0]:=0;  R[1]:=0;  R[2]:=-4;
  call('poaTransformAdd', [Result, 1, underBase, P,R,S]);
  R[0]:=0;  R[1]:=0;  R[2]:=2;
  call('poaTransformAdd', [Result, 2, underBase, P,R,S]);
  R[0]:=0;  R[1]:=0;  R[2]:=4;
  call('poaTransformAdd', [Result, 3, underBase, P,R,S]);
  R[0]:=0;  R[1]:=0;  R[2]:=-2;
  call('poaTransformAdd', [Result, 4, underBase, P,R,S]); }

  // backtime

  P[0]:=0;  P[1]:=0;  P[2]:=0.2;
  R[0]:=0;  R[1]:=0;  R[2]:=-2;
  call('poaTransformAdd', [Result, 8, BaseRoot, P,R,S]);
  P[0]:=0;  P[1]:=0;  P[2]:=-0.1;
  R[0]:=0;  R[1]:=0;  R[2]:=1;
  call('poaTransformAdd', [Result, 7, BaseRoot, P,R,S]);
  P[0]:=0;  P[1]:=0;  P[2]:=-0.2;
  R[0]:=0;  R[1]:=0;  R[2]:=2;
  call('poaTransformAdd', [Result, 6, BaseRoot, P,R,S]);
  P[0]:=0;  P[1]:=0;  P[2]:=0.1;
  R[0]:=0;  R[1]:=0;  R[2]:=-1;
  call('poaTransformAdd', [Result, 5, BaseRoot, P,R,S]);
                                                          {
  R[0]:=0;  R[1]:=0;  R[2]:=-4;
  call('poaTransformAdd', [Result, 8, underBase, P,R,S]);
  R[0]:=0;  R[1]:=0;  R[2]:=2;
  call('poaTransformAdd', [Result, 7, underBase, P,R,S]);
  R[0]:=0;  R[1]:=0;  R[2]:=4;
  call('poaTransformAdd', [Result, 6, underBase, P,R,S]);
  R[0]:=0;  R[1]:=0;  R[2]:=-2;
  call('poaTransformAdd', [Result, 5, underBase, P,R,S]);
                                                            }
 // call('glObjectVisible', [call('poaobjectid',[result, Base]), false]);
end;

end.
