unit skybox1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,dglOpenGL, AppEvnts, GLBmp, StdCtrls, ExtCtrls, glRender,Model,Model3ds,
ModelObj,ModelX,ModelMsa,glxsys, CategoryButtons, Geometry, restless;
type
TForm1 =
class(TForm)
ApplicationEvents1: TApplicationEvents;
Timer1: TTimer;
Button1: TButton;
procedure FormCreate(Sender: TObject);
procedure ApplicationEvents1Idle(Sender: TObject;
var Done: Boolean);
procedure FormResize(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private-Deklarationen }
public
DC : HDC;
RC : HGLRC;
procedure render;
end;
var
Form1: TForm1;
Timefactor:real;
StartTime, LoopTime: Integer;
glx:Tglx;
rlsObj : TRLSObject;
updateTime : Single;
const
ADVANCE_RATE = 25;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
restlessStartAnimation(rlsObj, 1, 1000);
end;
procedure TForm1.FormCreate(Sender: TObject);
var
Dummy : HPalette;
i:integer;
TMUs:integer;
begin
randomize;
glx:=Tglx.Create(form1);
glx.Parent:=self;
glx.Align:=alclient;
glx.GLXini(
DC,RC);
glx.extfilepath:=extractfilepath(paramstr(0));
//glx.GLXcreateSkybox('seiten', 'seiten', 'unten', 'oben', 'seiten', 'seiten',1000, 1000, 1000,list[0]);
glClearColor(0,0,0,0);
// restless initialisieren
restlessInit();
// objekt erstellt
rlsObj := restlessCreate();
//objekt laden
restlessLoadFromFile(rlsObj, PChar(glx.extfilepath + '
objects/Kran.rlsobj'));
//objektanimation laden
restlessAddAnimationFromFile(rlsObj, PChar(glx.extfilepath + '
objects/Kran.rlsani'));
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
DeActivateRenderingContext;
wglDeleteContext(RC);
ReleaseDC(
Handle,
DC);
//animation wieder freigeben
restlessDestroy(rlsObj);
glx.Free;
end;
procedure TForm1.render;
var i:integer;
begin
glMatrixMode(GL_MODELVIEW);
glClear(GL_COLOR_BUFFER_BIT
or GL_DEPTH_BUFFER_BIT);
glLoadIdentity;
glRotated(90,0,1,0);
gltranslatef(10,-1,1);
glRotated(90,0,1,0);
glPushMatrix();
glColor3f(1.0,0,0);
restlessRender(rlsObj);
// objekt rendern
glClear(GL_DEPTH_BUFFER_BIT);
glColor3f(0,1.0,0);
For i := 0
to restlessGetBoneCount(rlsObj)
do
restlessRenderBone(rlsObj, i, true);
//bones rendern
glPopMatrix();
SwapBuffers(
DC);
end;
procedure TForm1.FormResize(Sender: TObject);
begin
glx.GLXhandleResize;
end;
procedure TForm1.ApplicationEvents1Idle(Sender: TObject;
var Done: Boolean);
begin
LoopTime := gettickcount-starttime;
TimeFactor := LoopTime*0.00000000001+1;
StartTime := gettickcount;
// Update Restless:
updateTime := updateTime + TimeFactor;
If (updateTime > ADVANCE_RATE)
then
Begin
restlessAdvanceAnimation(rlsObj, updateTime);
updateTime := updateTime - ADVANCE_RATE;
End;
Render;
glx.SetFocus;
end;
end.