Results 1 to 7 of 7

Thread: Using L3DT maps within GLScene project.

  1. #1

    Using L3DT maps within GLScene project.

    I want to make a really large terrain using L3DT and to be able to use it within GLScene.. is this possible without lots of code?

  2. #2

    Using L3DT maps within GLScene project.

    This should be useful:
    http://www.sendspace.com/file/bl8i81

  3. #3

    Using L3DT maps within GLScene project.

    Excellent thanks

    I'm going to get the PRO version of L3DT so I can produce really large maps.

    Hopefully, this code will get me started.

  4. #4

    Using L3DT maps within GLScene project.

    I suppose it will, but the terrain loading process is rather slow if you plan to use it for a game. I'd suggest you to speed it up a little. In my opinion, it'd be nice if it was loaded by several threads and each of them loaded a different part of the map. This might be interesting for you:

    [pascal]
    {************************************************* ******************************
    Force© http://fp.cba.pl
    ForceSmallMap
    TForceSmallMap - Struktura zawieraj¬±ca szczeg??¬?owe dane o wycinku ¬?wiata, mo¬øe ¬?adowa?¶ swoje dane za pomoc¬± watku
    Lipiec 2007
    ************************************************** *****************************}
    unit ForceSmallMap;

    interface

    uses
    Classes, Windows, SysUtils ;

    type
    // Rekord mapy
    TForceMapRecord = record
    Image : integer;
    Typ : integer;
    end;
    PForceMapRecord = ^TForceMapRecord;

    TForceMapArray = array of array of TForceMapRecord;
    TForceSmallMap = record
    private
    FCells : TForceMapArray;
    FWidth : integer;
    FHeight : integer;
    public
    Loaded : pinteger;
    property Cells : TForceMapArray read FCells write FCells;
    property Width : integer read FWidth;
    property Height : integer read FHeight;

    constructor Create(Width : integer; Height : integer);
    procedure Finalize();

    procedure SetSize(Width,Height : integer);inline;
    function StaticLoadFromFile(FileName : string):integer;
    function ThreadLoadFromFile(FileName : string):integer;
    function StaticSaveToFile(FileName : string):integer;
    end;
    PForceSmallMap = ^TForceSmallMap;



    implementation

    type
    TThreadNameInfo = record
    FType: LongWord; // must be 0x1000
    FName: PChar; // pointer to name (in user address space)
    FThreadID: LongWord; // thread ID (-1 indicates caller thread)
    FFlags: LongWord; // reserved for future use, must be zero
    end;

    TForceMapLoader = class(TThread)
    private
    procedure SetName;
    procedure LoadFromFile();
    protected
    FSmallMap : PForceSmallMap;
    FFileName : string;
    procedure Execute; override;
    end;
    PForceMapLoader = ^TForceMapLoader;

    procedure TForceMapLoader.SetName;
    var
    ThreadNameInfo: TThreadNameInfo;
    begin
    ThreadNameInfo.FType := $1000;
    ThreadNameInfo.FName := 'TForceMapLoader';
    ThreadNameInfo.FThreadID := $FFFFFFFF;
    ThreadNameInfo.FFlags := 0;

    try
    RaiseException( $406D1388, 0, sizeof(ThreadNameInfo) div sizeof(LongWord), @ThreadNameInfo );
    except
    end;
    end;

    procedure TForceMapLoader.Execute;
    begin
    SetName;
    LoadFromFile();
    end;

    procedure TForceMapLoader.LoadFromFile();
    begin
    // £adowany
    FSmallMap^.Loaded^ := 1;
    FSmallMap^.StaticLoadFromFile(FFileName);
    // Za¬?adowany
    FSmallMap^.Loaded^ := 2;
    end;

    constructor TForceSmallMap.Create(Width : integer; Height : integer);
    begin
    SetSize(Width,Height);
    end;

    procedure TForceSmallMap.Finalize();
    begin
    SetSize(0,0);
    end;

    procedure TForceSmallMap.SetSize(Width,Height : integer);
    begin
    FWidth := Width;
    FHeight := Height;
    SetLength(FCells,Width,Height);
    end;

    function TForceSmallMap.StaticLoadFromFile(FileName : string):integer;
    var
    F : File;
    Res : integer;
    i: Integer;
    j: Integer;
    begin
    AssignFile(F,FileName);
    try
    Reset(F,1);
    BlockRead(F,FWidth,4,Res);
    if Res <> 4 then
    begin
    Result := -1;
    CloseFile(F);
    Exit;
    end;
    BlockRead(F,FHeight,4,Res);
    if Res <4> 0) and (FHeight > 0) then
    for i := 0 to FWidth - 1 do
    for j := 0 to FHeight - 1 do
    begin
    BlockRead(F,FCells[i,j],sizeof(TForceMapRecord),Res);
    if Res <> sizeof(TForceMapRecord) then
    begin
    Result := -1;
    CloseFile(F);
    Exit;
    end;
    end;
    except on E: Exception do
    begin
    Result := -2;
    CloseFile(F);
    Exit;
    end;
    end;
    Loaded^ := 2;
    CloseFile(F);
    Result := 0;
    end;

    function TForceSmallMap.ThreadLoadFromFile(FileName : string):integer;
    var
    W : TForceMapLoader;
    begin
    W := TForceMapLoader.Create(false);
    W.FSmallMap := @self;
    W.FFileName := FileName;
    W.FreeOnTerminate := True;
    W.Resume;
    Result := 0;
    end;

    function TForceSmallMap.StaticSaveToFile(FileName : string):integer;
    var
    F : File;
    Res : integer;
    i: Integer;
    j: Integer;
    begin
    AssignFile(F,FileName);
    try
    Rewrite(F,1);
    BlockWrite(F,FWidth,4,Res);
    if Res <> 4 then
    begin
    Result := -1;
    CloseFile(F);
    Exit;
    end;
    BlockWrite(F,FHeight,4,Res);
    if Res <4> 0) and (FHeight > 0) then
    for i := 0 to FWidth - 1 do
    for j := 0 to FHeight - 1 do
    begin
    BlockWrite(F,FCells[i,j],sizeof(TForceMapRecord),Res);
    if Res <> sizeof(TForceMapRecord) then
    begin
    Result := -1;
    CloseFile(F);
    Exit;
    end;
    end;
    except on E: Exception do
    begin
    Result := -2;
    CloseFile(F);
    Exit;
    end;
    end;
    CloseFile(F);
    Result := 0;
    end;

    end.
    [/pascal]

    It's only a suggestion, though.

  5. #5

    Using L3DT maps within GLScene project.

    I did find this on my travels...

    http://www.dave.serveusers.com/article.php?sid=22

    It's by the same guy responsible for the oxNewton GLScene.

  6. #6

    Using L3DT maps within GLScene project.

    EDIT
    Yeah, sorry for that. Indeed he's scary - he looks like a soldier!

  7. #7

    Using L3DT maps within GLScene project.

    Are you sure he wants that on an open forum like this?.. I've seen his picture on his site.. he looks a little scary :twisted:

    I've joined the forum there so I'll chat to him using that. Thanks for the link, however I'd edit your post to remove that email address if you're not sure he'd like it public.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •