|
@@ -104,8 +104,8 @@ type
|
|
|
PopupMenu: TPopupMenu;
|
|
|
miMerryCristmas: TMenuItem;
|
|
|
miHappyNewYear: TMenuItem;
|
|
|
- FFPiano: TGLFreeForm;
|
|
|
GLFireFXManager: TGLFireFXManager;
|
|
|
+ GLMaterialLibraryCM: TGLMaterialLibrary;
|
|
|
procedure FormCreate(Sender: TObject);
|
|
|
procedure CadencerProgress(Sender: TObject; const deltaTime,
|
|
|
newTime: Double);
|
|
@@ -129,6 +129,7 @@ type
|
|
|
FireLight : Single;
|
|
|
inPreview, inSaver : Boolean;
|
|
|
bStream : Cardinal;
|
|
|
+ function LoadTexture(Matname,Filename : string) : TGLLibMaterial;
|
|
|
end;
|
|
|
|
|
|
var
|
|
@@ -138,6 +139,14 @@ implementation
|
|
|
|
|
|
{$R *.dfm}
|
|
|
|
|
|
+
|
|
|
+function TMain.LoadTexture(Matname, Filename: string): TGLLibMaterial;
|
|
|
+begin
|
|
|
+ Result := GLMaterialLibraryCM.AddTextureMaterial(Matname, Filename);
|
|
|
+ Result.Material.Texture.Disabled := False;
|
|
|
+ Result.Material.Texture.TextureMode := tmDecal;
|
|
|
+end;
|
|
|
+
|
|
|
procedure TMain.FormCreate(Sender: TObject);
|
|
|
var
|
|
|
DataPath : String;
|
|
@@ -145,9 +154,12 @@ begin
|
|
|
Randomize;
|
|
|
DataPath := ExtractFilePath(ParamStr(0)) + 'data';
|
|
|
SetCurrentDir(DataPath);
|
|
|
+
|
|
|
+ // Skybox textures
|
|
|
+
|
|
|
FFFirTree.LoadFromFile('firtree.3ds');
|
|
|
FFFirePlace.LoadFromFile('fireplace.3ds');
|
|
|
- FFPiano.LoadFromFile('Piano.obj');
|
|
|
+
|
|
|
FireLight := 0.5;
|
|
|
FTYear.Text := '';
|
|
|
end;
|
|
@@ -177,8 +189,8 @@ end;
|
|
|
|
|
|
procedure TMain.FormKeyPress(Sender: TObject; var Key: Char);
|
|
|
begin
|
|
|
- Key:=#0;
|
|
|
- Application.Terminate;
|
|
|
+ Key := #0;
|
|
|
+ Application.Terminate;
|
|
|
end;
|
|
|
|
|
|
procedure TMain.FormMouseWheel(Sender: TObject; Shift: TShiftState;
|
|
@@ -189,130 +201,134 @@ end;
|
|
|
|
|
|
procedure TMain.ViewerDblClick(Sender: TObject);
|
|
|
begin
|
|
|
- if (not inPreview) and (not inSaver) and (not Application.Terminated) and (BorderStyle<>bsNone) then
|
|
|
- begin
|
|
|
- BorderStyle:=bsNone;
|
|
|
- FormStyle:=fsStayOnTop;
|
|
|
- Align:=alClient;
|
|
|
- end;
|
|
|
+ if (not inPreview) and (not inSaver) and (not Application.Terminated) and
|
|
|
+ (BorderStyle <> bsNone) then
|
|
|
+ begin
|
|
|
+ BorderStyle := bsNone;
|
|
|
+ FormStyle := fsStayOnTop;
|
|
|
+ Align := alClient;
|
|
|
+ end;
|
|
|
end;
|
|
|
|
|
|
procedure TMain.ViewerMouseDown(Sender: TObject; Button: TMouseButton;
|
|
|
Shift: TShiftState; X, Y: Integer);
|
|
|
begin
|
|
|
- mx:=x; my:=y;
|
|
|
+ mx := X;
|
|
|
+ my := Y;
|
|
|
end;
|
|
|
|
|
|
procedure TMain.ViewerMouseMove(Sender: TObject; Shift: TShiftState; X,
|
|
|
Y: Integer);
|
|
|
begin
|
|
|
- if Shift=[ssLeft] then begin
|
|
|
- Camera.MoveAroundTarget(my-y, mx-x);
|
|
|
- mx:=x; my:=y;
|
|
|
- end;
|
|
|
+ if Shift = [ssLeft] then
|
|
|
+ begin
|
|
|
+ Camera.MoveAroundTarget(my - Y, mx - X);
|
|
|
+ mx := X;
|
|
|
+ my := Y;
|
|
|
+ end;
|
|
|
end;
|
|
|
|
|
|
|
|
|
procedure TMain.CadencerProgress(Sender: TObject; const deltaTime,
|
|
|
newTime: Double);
|
|
|
begin
|
|
|
- FireLight:=ClampValue(fireLight+Random*0.4-0.2, 0, 1);
|
|
|
- LSFire.Diffuse.Color:=VectorLerp(clrYellow, VectorMake(0.5, 0, 0, 1),
|
|
|
- fireLight);
|
|
|
- LSFire.Position.Y:=FireLight*0.1;
|
|
|
-
|
|
|
- if inPreview then
|
|
|
- HUDSprite.Visible:=False;
|
|
|
-
|
|
|
- if HUDSprite.Visible then
|
|
|
- begin
|
|
|
- HUDSprite.Material.FrontProperties.Diffuse.Alpha:=
|
|
|
- HUDSprite.Material.FrontProperties.Diffuse.Alpha-deltaTime*0.03 ;
|
|
|
- if HUDSprite.Material.FrontProperties.Diffuse.Alpha<0.01 then
|
|
|
- HUDSprite.Visible:=False;
|
|
|
- end;
|
|
|
- DCFirTree.Turn(deltaTime);
|
|
|
- Viewer.Invalidate();
|
|
|
+ FireLight := ClampValue(FireLight + Random * 0.4 - 0.2, 0, 1);
|
|
|
+ LSFire.Diffuse.Color := VectorLerp(clrYellow, VectorMake(0.5, 0, 0, 1),
|
|
|
+ FireLight);
|
|
|
+ LSFire.Position.Y := FireLight * 0.1;
|
|
|
+
|
|
|
+ if inPreview then
|
|
|
+ HUDSprite.Visible := False;
|
|
|
+
|
|
|
+ if HUDSprite.Visible then
|
|
|
+ begin
|
|
|
+ HUDSprite.Material.FrontProperties.Diffuse.Alpha :=
|
|
|
+ HUDSprite.Material.FrontProperties.Diffuse.Alpha - deltaTime * 0.03;
|
|
|
+ if HUDSprite.Material.FrontProperties.Diffuse.Alpha < 0.01 then
|
|
|
+ HUDSprite.Visible := False;
|
|
|
+ end;
|
|
|
+ DCFirTree.Turn(deltaTime);
|
|
|
+ Viewer.Invalidate();
|
|
|
end;
|
|
|
|
|
|
procedure TMain.TimerTimer(Sender: TObject);
|
|
|
var
|
|
|
- i : Integer;
|
|
|
- t : TDateTime;
|
|
|
- buf : String;
|
|
|
- y, m, d : Word;
|
|
|
- TheChristmas, isArrived : Boolean;
|
|
|
+ i: Integer;
|
|
|
+ t: TDateTime;
|
|
|
+ buf: String;
|
|
|
+ Y, m, d: Word;
|
|
|
+ TheChristmas, isArrived: Boolean;
|
|
|
|
|
|
begin
|
|
|
- Caption:=Format('%.1f FPS', [Viewer.FramesPerSecond]);
|
|
|
- Viewer.ResetPerformanceMonitor;
|
|
|
- if SMBASS.Active and (bStream=0) then
|
|
|
- begin
|
|
|
- bStream:=BASS_StreamCreateFile(False, PAnsiChar('Jingle_Bells_64.mp3'), 0, 0, BASS_STREAM_AUTOFREE);
|
|
|
- BASS_ChannelPlay(bStream, True);
|
|
|
- end;
|
|
|
- DecodeDate(Now(), y, m, d);
|
|
|
-// if miMerryCristmas.Checked then
|
|
|
- begin
|
|
|
- t:=EncodeDate(y, 12, 25)-Now();
|
|
|
- FTCongratulations.Text := 'Merry Christmas!';
|
|
|
- end;
|
|
|
-(*
|
|
|
- else
|
|
|
- begin
|
|
|
- t:=EncodeDate(y+1, 01, 01)-Now();
|
|
|
- FTCongratulations.Text := 'Happy New Year!';
|
|
|
- FTYear.Text:= IntToStr(y+1);
|
|
|
- end;
|
|
|
-*)
|
|
|
- if (t<1) and (t>-1) then
|
|
|
- DCGifts.Visible:=True;
|
|
|
- if t>=2 then
|
|
|
- begin
|
|
|
- buf:=IntToStr(Trunc(t))+' days, ';
|
|
|
- i:=Round(Frac(t)*24);
|
|
|
- if i>1 then
|
|
|
- buf:=buf+IntToStr(i)+' hours...'
|
|
|
- else
|
|
|
- buf:=buf+IntToStr(i)+' hour...';
|
|
|
- FTCountDown.Text:=buf;
|
|
|
- end
|
|
|
- else
|
|
|
- begin
|
|
|
- t:=t*24;
|
|
|
- if t>1 then
|
|
|
- begin
|
|
|
- buf:=IntToStr(Trunc(t))+' hours, ';
|
|
|
- i:=Round(Frac(t)*60);
|
|
|
- if i>1 then
|
|
|
- buf:=buf+IntToStr(i)+' minutes...'
|
|
|
- else buf:=buf+IntToStr(i)+' minute...';
|
|
|
- FTCountDown.Text:=buf;
|
|
|
- end
|
|
|
+ Caption := Format('%.1f FPS', [Viewer.FramesPerSecond]);
|
|
|
+ Viewer.ResetPerformanceMonitor;
|
|
|
+ if SMBASS.Active and (bStream = 0) then
|
|
|
+ begin
|
|
|
+ bStream := BASS_StreamCreateFile(False, PAnsiChar('Jingle_Bells_64.mp3'), 0,
|
|
|
+ 0, BASS_STREAM_AUTOFREE);
|
|
|
+ BASS_ChannelPlay(bStream, True);
|
|
|
+ end;
|
|
|
+ DecodeDate(Now(), Y, m, d);
|
|
|
+ if miMerryCristmas.Checked then
|
|
|
+ begin
|
|
|
+ t := EncodeDate(Y, 12, 25) - Now();
|
|
|
+ FTCongratulations.Text := 'Merry Christmas!';
|
|
|
+ end
|
|
|
+ else
|
|
|
+ begin
|
|
|
+ t:=EncodeDate(y+1, 01, 01)-Now();
|
|
|
+ FTCongratulations.Text := 'Happy New Year!';
|
|
|
+ FTYear.Text:= IntToStr(y+1);
|
|
|
+ end;
|
|
|
+ if (t < 1) and (t > -1) then
|
|
|
+ DCGifts.Visible := True;
|
|
|
+ if t >= 2 then
|
|
|
+ begin
|
|
|
+ buf := IntToStr(Trunc(t)) + ' days, ';
|
|
|
+ i := Round(Frac(t) * 24);
|
|
|
+ if i > 1 then
|
|
|
+ buf := buf + IntToStr(i) + ' hours...'
|
|
|
+ else
|
|
|
+ buf := buf + IntToStr(i) + ' hour...';
|
|
|
+ FTCountDown.Text := buf;
|
|
|
+ end
|
|
|
+ else
|
|
|
+ begin
|
|
|
+ t := t * 24;
|
|
|
+ if t > 1 then
|
|
|
+ begin
|
|
|
+ buf := IntToStr(Trunc(t)) + ' hours, ';
|
|
|
+ i := Round(Frac(t) * 60);
|
|
|
+ if i > 1 then
|
|
|
+ buf := buf + IntToStr(i) + ' minutes...'
|
|
|
else
|
|
|
- begin
|
|
|
- t:=t*60;
|
|
|
- FTCountDown.Text:= IntToStr(Trunc(t))+' minutes, '
|
|
|
- +IntToStr(Round(Frac(t)*60))+' seconds...';
|
|
|
- end;
|
|
|
- end;
|
|
|
+ buf := buf + IntToStr(i) + ' minute...';
|
|
|
+ FTCountDown.Text := buf;
|
|
|
+ end
|
|
|
+ else
|
|
|
+ begin
|
|
|
+ t := t * 60;
|
|
|
+ FTCountDown.Text := IntToStr(Trunc(t)) + ' minutes, ' +
|
|
|
+ IntToStr(Round(Frac(t) * 60)) + ' seconds...';
|
|
|
+ end;
|
|
|
+ end;
|
|
|
end;
|
|
|
|
|
|
procedure TMain.ScreenSaverCloseQuery(Sender: TObject;
|
|
|
var CanClose: Boolean);
|
|
|
begin
|
|
|
- Application.Terminate;
|
|
|
- CanClose:=False;
|
|
|
+ Application.Terminate;
|
|
|
+ CanClose := False;
|
|
|
end;
|
|
|
|
|
|
procedure TMain.ScreenSaverExecute(Sender: TObject);
|
|
|
begin
|
|
|
- inSaver:=True;
|
|
|
+ inSaver := True;
|
|
|
end;
|
|
|
|
|
|
procedure TMain.ScreenSaverPreview(Sender: TObject; previewHwnd: HWND);
|
|
|
begin
|
|
|
- inPreview:=True;
|
|
|
+ inPreview := True;
|
|
|
end;
|
|
|
|
|
|
end.
|