Page 3 of 7 FirstFirst 12345 ... LastLast
Results 21 to 30 of 62

Thread: Final3D SDL Engine 2007

  1. #21
    Co-Founder / PGD Elder WILL's Avatar
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    6,107
    Blog Entries
    25

    Final3D SDL Engine 2007

    Hey Andy, I've been worked with ll of the keyboard, joystick and mouse controls under SDL myself so if you don't understand something feel free to ask, I should know the answer.

    I've created my own library to extend the usage of the existing SDL functions allowing for user-defined controls and such.

    One of the tricky parts was figuring out a way to detect mouse wheel scrolling. I did this by creating a record/class that simply turned on a flag for the appropriate direction once the MWB event was found in the event queue. I also made a 'ResetMouse' function that would take down the flag as there was no other was to detect that the user has stopped scrolling. Doesn't exist as far as JEDI-SDL BETA 1 is concerned.

    If you run your own reset code after you are done your player controls functionality code, it should be a simple matter of waiting to see if the wheel is scrolled again the next frame. I actually found this to be a simple and easy and accurate way to determine if the player is scrolling currently or not.
    Jason McMillen
    Pascal Game Development
    Co-Founder





  2. #22

    Final3D SDL Engine 2007

    If I good understand, you have finished lib for game Input defined by user. OK. Then i don't need implementing it to F3D. But then i need source for including to F3D. When willl be released?

    P.Solution with timer dont work good on my home PC (((((( Mouse FreeLook sometimes, jump about big angle (is calculated from Mouse Delta X/Y)

    If you have time, plese look on my code, what is wrong in my logic.

    http://final3d.intelligentdevelopmen...s/F3D_test.zip

    In Win32 F3D version i never had this problems, because i used DXInput and DXTimer and latter my Timer class. With correct working timer + input i can't continue

    My old Timer class:

    [pascal]
    unit F3D_Timer;

    interface

    uses Windows, Controls, Messages, SysUtils, Classes, Forms,

    dglOpenGL;

    type TProcedureEvent = procedure of object;
    { The type of event that is called by the timer. }
    Type TF3D_TimerEvent = procedure(Sender: TObject; FrameTime: Single) of object;


    Type TF3D_Timer = class(TComponent)
    private
    { Private declarations }
    FEnabled : Boolean;
    FActive : Boolean;
    FActiveOnly : Boolean;
    FInterval : Cardinal;
    FInitialized : Boolean;
    FFrequency : Int64;

    // Event
    FOnTimer : TF3D_TimerEvent;

    // Time
    FAppStart : Single;
    FLastTime : Single;

    // Frame information
    FFrameTimes : Single;
    FFrameCount : Int64;
    FFrameRate : Integer;
    FFrameRateCounter: Integer;
    FFrameRateTime : Single;
    FDeltaTime : Single;

    function GetCurrentTime: Single;
    function GetElapsedTime: Single;


    function AppProc(var Message: TMessage): Boolean;
    procedure AppIdle(Sender: TObject; var Done: Boolean);

    procedure Finalize;
    procedure Initialize;
    procedure Resume;
    procedure Suspend;

    procedure SetActiveOnly(Value: Boolean);
    procedure SetEnabled (Value: Boolean);
    procedure SetInterval (Value: Cardinal);
    protected
    {@exclude}
    procedure Loaded; override;
    public
    OnBeginFrame :TProcedureEvent;
    OnEndFrame :TProcedureEvent;

    DeltaTime : Single;
    {@exclude}
    constructor Create(AOwner: TComponent); override;
    {@exclude}
    destructor Destroy; override;
    function NPXDeltaTime: Single;
    { The current framerate, is weighted over the last 500 ms. }
    property FrameRate : Integer read FFrameRate;
    { The number of frames rendered since program start. }
    property FrameCount : Int64 read FFrameCount;
    { The time elapsed since program start, in milliseconds. }
    property ElapsedTime: Single read GetElapsedTime;
    published
    { Determines if the timer shall be active or not. }
    property Enabled : Boolean read FEnabled write SetEnabled;
    { The interval of the timer, in milliseconds. If zero then max speed. }
    property Interval : Cardinal read FInterval write SetInterval;
    { This tells if the timer shall be disabled when the window loses focus. }
    property ActiveOnly : Boolean read FActiveOnly write SetActiveOnly;
    { The main timer event, this is called with the interval in milliseconds. }
    property OnTimer : TF3D_TimerEvent read FOnTimer write FOnTimer;
    end;



    implementation




    // Class TGLTimer
    //================================================== ============================
    constructor TF3D_Timer.Create(AOwner: TComponent);
    begin
    inherited Create(AOwner);
    FActiveOnly:= True;
    FActive := True;
    FEnabled := True;
    Interval := 1;
    Application.HookMainWindow(AppProc);

    QueryPerformanceFrequency(FFrequency);
    FAppStart :=GetCurrentTime;
    FFramerateTime :=FAppStart;
    FLastTime :=FAppStart;
    FFrameRate :=0;
    FFrameRateCounter :=0;
    FFrameCount :=0;
    end;

    //------------------------------------------------------------------------------
    destructor TF3D_Timer.Destroy;
    begin
    Finalize;
    Application.UnHookMainWindow(AppProc);
    inherited ;
    end;


    //------------------------------------------------------------------------------
    procedure TF3D_Timer.AppIdle(Sender: TObject; var Done: Boolean);
    var FrameTime : Single;
    var FrameRateTime: Single;
    begin
    Done := False;
    FrameTime := (GetCurrentTime - FLastTime);
    IF (FrameTime >= FInterval) then begin
    FLastTime:=GetCurrentTime;

    Inc(FFramerateCounter);

    FrameRateTime:=(FLastTime - FFrameRateTime);
    IF FrameRateTime > 1000 then begin
    IF FFramerateCounter = 0 then FFramerateCounter:=1;
    FFrameRate := Round(1000/(FrameRateTime/FFramerateCounter));
    FFramerateCounter := 0;
    FFramerateTime := GetCurrentTime();
    end;

    FDeltaTime:=(FFrameTimes + FrameTime) * 0.5 ;
    DeltaTime:=FDeltaTime * 0.1;
    if Assigned(FOnTimer) then OnBeginFrame();
    if Assigned(FOnTimer) then FOnTimer(Self, FDeltaTime);

    if Assigned(FOnTimer) then OnEndFrame();


    FFrameTimes:=FrameTime;

    Inc(FFrameCount);
    end;
    end;

    //------------------------------------------------------------------------------
    function TF3D_Timer.AppProc(var Message: TMessage): Boolean;
    begin
    Result:= False;
    case Message.Msg of
    CM_ACTIVATE : If FInitialized and FActiveOnly then Resume;
    CM_DEACTIVATE: If FInitialized and FActiveOnly then Suspend;
    end;
    end;

    //------------------------------------------------------------------------------
    procedure TF3D_Timer.Initialize;
    begin
    Finalize;

    if ActiveOnly then begin
    if Application.Active then
    Resume;
    end else
    Resume;
    FInitialized := True;
    end;

    //------------------------------------------------------------------------------
    procedure TF3D_Timer.Finalize;
    begin
    if FInitialized then begin
    Suspend;
    FInitialized := False;
    end;
    end;

    //------------------------------------------------------------------------------
    procedure TF3D_Timer.Loaded;
    begin
    inherited Loaded;
    if (not (csDesigning in ComponentState)) and FEnabled then
    Initialize;
    end;

    //------------------------------------------------------------------------------
    procedure TF3D_Timer.Resume;
    begin
    // FAppStart:=FAppStart + (GetCurrentTime-FSuspendTime);
    FLastTime:=GetCurrentTime;

    Application.OnIdle:= AppIdle;
    end;

    //------------------------------------------------------------------------------
    procedure TF3D_Timer.Suspend;
    begin
    // FSuspendTime:=GetCurrentTime;
    Application.OnIdle:= nil;
    end;

    //------------------------------------------------------------------------------
    procedure TF3D_Timer.SetActiveOnly(Value: Boolean);
    begin
    if FActiveOnly<>Value then
    begin
    FActiveOnly := Value;

    if Application.Active and FActiveOnly then
    if FInitialized and FActiveOnly then Suspend;
    end;
    end;

    //------------------------------------------------------------------------------
    procedure TF3D_Timer.SetEnabled(Value: Boolean);
    begin
    if FEnabled<>Value then
    begin
    FEnabled := Value;
    if ComponentState*[csReading, csLoading]=[] then
    if FEnabled then Initialize else Finalize;
    end;
    end;

    //------------------------------------------------------------------------------
    procedure TF3D_Timer.SetInterval(Value: Cardinal);
    begin
    FInterval:= Value;
    end;



    //------------------------------------------------------------------------------
    function TF3D_Timer.GetCurrentTime: Single;
    var Time : Int64;
    begin
    QueryPerformanceCounter(Time);
    Result:= (Time / FFrequency) * 1000;
    end;

    //------------------------------------------------------------------------------
    function TF3D_Timer.GetElapsedTime: Single;
    begin
    Result:=GetCurrentTime - FAppStart;
    end;


    function TF3D_Timer.NPXDeltaTime: Single;
    var Time : Int64;
    begin
    QueryPerformanceCounter(Time);
    Result:=((Time - FAppStart)/(FFrequency*1000))*0.01;
    end;


    end.
    [/pascal]

    Now i seems as stupid bastard
    C2D X6800, 4GBRAM, NV8800GTX, Vista x64 Ultimate

  3. #23

    Final3D SDL Engine 2007

    new version 0.10 :



    - VBO Manager with automatic schiwtch between Vertex buffer object or Vertex Array
    - Geometry Class
    - Models Data Manager class
    - Skybox class
    - Startup preloader for textures, materials, events, models defined in external file



    - partly fixed problem with mouse control, but for better scene control you must switch VSync ON - i wating for help

    - all scene items as models, textures, surfaces, events must by added first to precache file definition and the load before are used.

    - included demos are only as samples howto work with classes, don't show visual possibility
    C2D X6800, 4GBRAM, NV8800GTX, Vista x64 Ultimate

  4. #24

    Final3D SDL Engine 2007

    Quote Originally Posted by andygfx
    WHEEL_UP and WHEEL_DOWN return always 1 ((
    That is because SDL does not tell you how many pixels have moved only that the event has occured. If it is always 1 make sure that the SDL_PumpEvents; to update the various structures.

    Btw, the SDlInputManger supports hooking events up to things like OnMouseWheel which will fire every time a wheel is moved and it will tell you wether it was up or down.
    <br /><br />There are a lot of people who are dead while they are still alive. I want to be alive until the day I die.<br />-= Paulo Coelho =-

  5. #25

    Final3D SDL Engine 2007

    Btw, have you looked at sdlticks.pas and the TimerClass there in?
    <br /><br />There are a lot of people who are dead while they are still alive. I want to be alive until the day I die.<br />-= Paulo Coelho =-

  6. #26

    Final3D SDL Engine 2007

    Quote Originally Posted by savage
    Btw, have you looked at sdlticks.pas and the TimerClass there in?
    NO. I will try this tonight.
    C2D X6800, 4GBRAM, NV8800GTX, Vista x64 Ultimate

  7. #27

    Final3D SDL Engine 2007

    New release of F3D v0.11

    Actual features list:

    - WinXP x86/ Vista x64 / Linux (not tested)
    - OpenGL 2.0
    - SDL lib
    - pascal language
    - Viewport class
    - HUD class
    - Texture Factory class (currently is used DevIL lib)
    - Font class
    - Font Manager class (accept Nitrogen Font Studio 4 file - tga/composit)
    - Image Manager class (will be used for GUI)
    - SDL Input control class
    - Movement control class
    - Camera class
    - Billboard Manager
    - Material manager
    - Material Event Manager
    - Surface Manager
    - GLSL
    - Shader Manager
    - VBO Manager with automatic schiwtch between Vertex object or Array
    - Geometry Class
    - Models Data Manager class
    - Skybox class
    - Startup preloader for textures, materials, events, models defined in external file
    - Scene Manager class
    - Newton Physics class

    ToDo:

    - Skined GUI
    - GUI Manager
    - Sprite3D Manager
    - CAL3D Animation class
    - fix problem with VBO on Vista
    - fix problem with mouse movement
    - LUA wrapper for all classes

    SRC/BIN from http://final3d.intelligentdevelopment.sk/
    C2D X6800, 4GBRAM, NV8800GTX, Vista x64 Ultimate

  8. #28

    Final3D SDL Engine 2007

    Its a framework of openGL + SDL :?:
    From brazil (:

    Pascal pownz!

  9. #29

    Final3D SDL Engine 2007

    Yes. Download and try. If you have comments write me.
    C2D X6800, 4GBRAM, NV8800GTX, Vista x64 Ultimate

  10. #30

    Final3D SDL Engine 2007

    Hi andygfx. I love the idea of having a modern 3D engine using opengl + sdl! Will check it out as soon I have the time to do so. Maybe I will use it for an own project then . So keep on working ...

Page 3 of 7 FirstFirst 12345 ... LastLast

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
  •