1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140
|
{
GLTICKTICK : 11/03/2006
by f0xi [delphifr]
}
unit Main;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, GLObjects, GLGeomObjects, GLScene, GLMisc, GLCadencer,
GLWin32Viewer, Menus, ExtCtrls, GLMirror, GLzBuffer, GLShadowPlane,
GLShadowVolume, GLWaterPlane, GLTexture, GLPhongShader, GLSpaceText;
type
TForm1 = class(TForm)
GLScene1: TGLScene;
GLSceneViewer1: TGLSceneViewer;
GLCamera1: TGLCamera;
GLLightSource1: TGLLightSource;
Cameras: TGLDummyCube;
GLHorloge: TGLDummyCube;
GLSecondes: TGLDummyCube;
GLMinutes: TGLDummyCube;
GLCylinder1: TGLCylinder;
GLHours: TGLDummyCube;
Timer1: TTimer;
GLAnnulus5: TGLAnnulus;
GLCube1: TGLCube;
GLCube2: TGLCube;
GLH0: TGLSphere;
GLHSPH: TGLDummyCube;
GLH6: TGLSphere;
GLH3: TGLSphere;
GLH9: TGLSphere;
GLH1: TGLSphere;
GLH2: TGLSphere;
GLH4: TGLSphere;
GLH5: TGLSphere;
GLH7: TGLSphere;
GLH8: TGLSphere;
GLH11: TGLSphere;
GLH10: TGLSphere;
GLShadowVolume1: TGLShadowVolume;
GLCylinder2: TGLCylinder;
GLCube3: TGLCube;
GLAnnulus6: TGLAnnulus;
GLCube5: TGLCube;
GLAnnulus1: TGLAnnulus;
GLPhongShader1: TGLPhongShader;
GLMaterialLibrary1: TGLMaterialLibrary;
GLAnnulus2: TGLAnnulus;
procedure Timer1Timer(Sender: TObject);
procedure FormMouseWheelDown(Sender: TObject; Shift: TShiftState;
MousePos: TPoint; var Handled: Boolean);
procedure FormMouseWheelUp(Sender: TObject; Shift: TShiftState;
MousePos: TPoint; var Handled: Boolean);
private
{ Déclarations privées }
public
{ Déclarations publiques }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
uses Math, // on as toujours besoin des maths ;)
DateUtils; // et du temps...
Type
// type permettant de stocker un temps issus de GetTickCount
TTickTime = record
H,M,S,Cs,Ms : integer;
end;
// type permettant de stocker des degrés issus d'un temps
TDegreTime = record
H,M,S,Cs : extended;
end;
Var
TT : TTickTime; // Le temps par GetTickCount
TD : TDegreTime; // Les degrés du temps sur un cadran
CSRot : boolean = false;
SCRot : boolean = false;
MNRot : boolean = false;
HRRot : boolean = false;
procedure GetNow(out V : TTickTime);
var t : TTime;
const
HCOP : array[0..23] of byte = (0,1,2,3,4,5,6,7,8,9,10,11,0,1,2,3,4,5,6,7,8,9,10,11);
begin
// on recupere l'heures systeme courrante
T := Time;
Form1.Caption := 'GL Tick Tick! '+TimeToStr(T);
// on recupere les Centiemes de secondes
V.Cs := MilliSecondOf(t) div 10;
// on recupere les secondes
V.S := SecondOf(t);
// on recupere les minutes
V.M := MinuteOf(t);
// on recupere les heures
V.H := HCOP[HourOf(t)];
end;
procedure ColLight(Sp : TGLSphere);
begin
Sp.Material.LibMaterialName := 'PhongSPHLight';
end;
procedure ColShadow(Sp : TGLSphere);
begin
Sp.Material.LibMaterialName := 'PhongSPHShadow';
end;
procedure TForm1.Timer1Timer(Sender: TObject);
var TDH : string;
X : integer;
begin
// TICKTIME
GetNow(TT);
// DEGRETIME :: 1 cadran = 360°
// K = 30 = Heure par cadran = 360/12
// K = 0.5= Minutes par 12 heure par cadran = 360/720
TD.H := ((TT.H*60)+TT.M) * 0.5;
// K = 6 = Minutes par cadran = 360/60
TD.M := TT.M * 6 ;
// K = 6 = Secondes par cadran = 360/60
TD.S := TT.S * 6 ;
// K = 3.6 = Centiemes de secondes par cadran = 360/100
TD.Cs := TT.Cs * 3.6;
ColLight((GLHSPH.Children[TT.H] as TGLSphere));
for x := 0 to 11 do if x <> TT.H then ColShadow((GLHSPH.Children[X] as TGLSphere));
GLSecondes.RollAngle := TD.S;
GLMinutes.RollAngle := TD.M;
GLHours.RollAngle := TD.H;
end;
procedure TForm1.FormMouseWheelDown(Sender: TObject; Shift: TShiftState;
MousePos: TPoint; var Handled: Boolean);
begin
with GLSceneviewer1 do if FieldOfView > 58 then FieldOfView := FieldOfView - 1;
end;
procedure TForm1.FormMouseWheelUp(Sender: TObject; Shift: TShiftState;
MousePos: TPoint; var Handled: Boolean);
begin
with GLSceneviewer1 do if FieldOfView < 180 then FieldOfView := FieldOfView + 1;
end;
end. |
Partager