MODULE Trianger;

(*****************************************************************************)
(*                                                                           *)
(*  Modul: Trianger                         Version 1.1 vom 21. April  1991  *)
(*                                                                           *)
(*  Für M2Amiga Modula-2 von Olaf Pfeiffer                                   *)
(*                                                                           *)
(*---------------------------------------------------------------------------*)
(*                                                                           *)
(*   Dieses Programm wurde mit Hilfe der Module der GraphicTreasures ge-     *)
(*   schrieben. Compiliert und gelinkt wurde das Programm mit der neuen      *)
(*   Version 4.0 des M2Amiga-Systems !!!                                     *)
(*                                                                           *)
(*****************************************************************************)


FROM SYSTEM       IMPORT SHIFT;

(* Die folgenden Importe beziehen sich auf die GraphicTreasures *)

FROM GfxDecs      IMPORT GfxMode, GfxPtr, Voxel, Direction, ScenePtr, Pixel;
FROM GfxSystem    IMPORT OpenStdGfx, CloseGfx, ClearGfx, GfxToFront;
FROM GfxMouse     IMPORT CheckMPress, GetMPos;
FROM Camera       IMPORT SetCameraTo;
FROM System3D     IMPORT SetVoxelTo, SetDirectTo;
FROM SceneLib     IMPORT InitScene, EndScene, TurnObjectX, RecolorObject,
                         CopyObject, TurnObject, MoveObjectTo;
FROM ShapeLib     IMPORT RotatePoly;
FROM ShowScene    IMPORT SimpleTrace;
FROM ColorLib     IMPORT SetColors, SetEHBColors;

VAR Gfx:         ARRAY BOOLEAN OF GfxPtr;
    Scene:       ScenePtr;
    Lin:         ARRAY [0..3] OF Pixel;
    tur, lit:    Direction;
    pos:         Voxel;
    bool:        BOOLEAN;
    x, y:        INTEGER;

BEGIN
  Gfx[TRUE]  := OpenStdGfx(EHB,FALSE);       (* Zwei "Grafik-Screen"s öffnen *)
  Gfx[FALSE] := OpenStdGfx(EHB,FALSE);
  SetColors(Gfx[TRUE], 0,0,"555 999 46A A45 37B 000");
  SetColors(Gfx[FALSE],0,0,"555 999 46A A45 37B 000");
  SetEHBColors(Gfx[TRUE], 0,"999 46A A45 37B 000");
  SetEHBColors(Gfx[FALSE],0,"999 46A A45 37B 000");
  Scene := InitScene();
  Lin[0].x  := -3500; Lin[0].y  := 12000;   (* 2D - Dreieck *)
  Lin[1].x  :=     0; Lin[1].y  := 18000;
  Lin[2].x  :=  3500; Lin[2].y  := 12000;
  Lin[3].x  := -3500; Lin[3].y  := 12000;
  SetDirectTo(tur,0,0,0);
  SetVoxelTo(pos,0,7000,0);
  RotatePoly(Scene,"1.Thorus",4,4,Lin,tur,pos,1);
  CopyObject(Scene,Scene,"1.Thorus","2.Thorus");
  RecolorObject(Scene,"1.Thorus",FALSE,3);
  RecolorObject(Scene,"2.Thorus",FALSE,4);
  SetDirectTo(tur,0,900,0);
  TurnObject(Scene,"2.Thorus",tur);
  SetVoxelTo(pos,0,-7000,0);
  MoveObjectTo(Scene,"2.Thorus",pos);
  SetDirectTo(lit,0,0,0);
  WHILE CheckMPress(Gfx[bool],TRUE) = 1 DO
    bool := NOT bool;
    GetMPos(Gfx[bool],x,y);
    x := 200 + SHIFT(x,2);
    y := 100 - SHIFT(y,3);
    SetDirectTo(tur,y,x,0);
    SetCameraTo(Gfx[bool],100,tur,0,0,0);
    ClearGfx(Gfx[bool]);
    SimpleTrace(Gfx[bool],Scene,lit,-1);
    GfxToFront(Gfx[bool]);
    TurnObjectX(Scene,"1.Thorus",50);
  END;
  EndScene(Scene);
  CloseGfx(Gfx[TRUE]); CloseGfx(Gfx[FALSE]);
END Trianger.


