Results 1 to 5 of 5

Thread: spider animation (again)

  1. #1

    spider animation (again)

    in the example posted by Eros (August 25, 200 here:
    http://community.thinbasic.com/index.php?topic=1983.0
    there is a spider animation , and for just fun i want to draw 5 spiders (or more) so i have used the tbgl_translate and a loop from -4 to 0, i want to draw also a galaxy so as it is the home of the spiders.
    some notes:
    1- the galaxy picture appears as dim and not as vivid like the original picture.
    2- other criticism, reviews ?? appreciated.

    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	spiders.PNG 
Views:	83 
Size:	62.6 KB 
ID:	6730  
    Attached Files Attached Files

  2. #2
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    6,799
    Blog Entries
    3
    Rep Power
    693

    Re: spider animation (again)

    Hi Zak,

    pretty scary render of invasion

    The reason you had galaxy dark was that you did not disabled lighting.

    If you change the Square procedure to following, you will see the galaxy will be as bright as it should:
    [code=thinbasic]
    Function square()

    ' -- Enable texturing, but just for the part of code
    TBGL_PushState %TBGL_TEXTURING

    ' -- Disable lighting, but just for part of code
    TBGL_PushStateProtect %TBGL_LIGHTING

    ' -- Bind texture #2
    TBGL_BindTexture 2
    TBGL_Color 255,255,255
    TBGL_Translate 2.5, 1, -1

    TBGL_BeginPoly %GL_QUADS ' Starts polygon definition based on 4 vertexes

    TBGL_TexCoord2D 0.0, 0.0 : TBGL_Vertex -2, -2, 0.0
    TBGL_TexCoord2D 1.0, 0.0 : TBGL_Vertex 2, -2, 0.0
    TBGL_TexCoord2D 1.0, 1.0 : TBGL_Vertex 2, 2, 0.0
    TBGL_TexCoord2D 0.0, 1.0 : TBGL_Vertex -2, 2, 0.0

    TBGL_EndPoly ' Ends polygon definition

    TBGL_PopStateProtect
    TBGL_PopState

    End Function
    [/code]


    Petr
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 7 64bit - Intel Core 2 Duo T6600 @ 2.2GHz - 4 GB RAM - NVIDIA GeForce G210M 512MB
    Windows 8 64bit - Intel Core i5-3350P @ 3.1GHz - 8 GB RAM - NVIDIA GeForce GT640 3GB

  3. #3
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    6,799
    Blog Entries
    3
    Rep Power
    693

    Re: spider animation (again)

    One more thing,

    I have seen in your code stuff like:
    [code=thinbasic]
    TBGL_UseTexture 2 : TBGL_BindTexture 2
    [/code]

    That is not entirely correct. TBGL_UseTexture was made obsolete (as help file says) mainly due its confusing name which leads to situation people use it like you did.
    The replacement is TBGL_UseTexturing, which is slightly more clear.

    So the correct variation to your code would be:
    [code=thinbasic]
    TBGL_UseTexturing(%TRUE) ' -- Enables texturing generally
    TBGL_BindTexture(2) ' -- Binds texture #2 to be used
    [/code]
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 7 64bit - Intel Core 2 Duo T6600 @ 2.2GHz - 4 GB RAM - NVIDIA GeForce G210M 512MB
    Windows 8 64bit - Intel Core i5-3350P @ 3.1GHz - 8 GB RAM - NVIDIA GeForce GT640 3GB

  4. #4

    Re: spider animation (again)

    thanks Petr,
    now the galaxy appears bright as it should be.
    how much you estimate the pc will overloaded from many many spiders we may display ??
    thanks

  5. #5
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    6,799
    Blog Entries
    3
    Rep Power
    693

    Re: spider animation (again)

    Hi Zak,

    it depends!

    From purely technological view, your spiders are rendered using the most straightforward approach - via the predefined primitives. They are currently handled using Vertex Arrays.
    If you render the same shape multiple times, you could take advantage of display lists - one for head, and one for each leg part.

    To maximize the performance, and reduce the FOR/NEXT overhead, you could consider recreating the scene using scene-entity system. That assures the bigger part runs at compiled speed.

    The whole overhead highly depends on how many spiders are in the view, and how often do you switch states (enabling/disabling texturing, changing textures). If we go into extreme, it would be advantageous to render just heads first, with once bound texture 1, and then all the legs, which have no texture. But fact is code gets complicated this way.

    The raw performance varies, depends on model "batch" size, and graphic card performance.
    For example my "record" with GeForce 9500GT was rendering of 8 000 000 polygons at smooth speed. But on the other side, Intel cards I could test have problems even with scenes under 100 000 polygons.*

    There is ellegant approach on modern cards, called "geometry instancing", which provides even better performance for multiple "stamps" of same object in the scene. But this technique is limited to modern models of GeForces and Radeons.


    Petr

    * Lighted, textured, colored
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 7 64bit - Intel Core 2 Duo T6600 @ 2.2GHz - 4 GB RAM - NVIDIA GeForce G210M 512MB
    Windows 8 64bit - Intel Core i5-3350P @ 3.1GHz - 8 GB RAM - NVIDIA GeForce GT640 3GB

Similar Threads

  1. MD2 Animation
    By Petr Schreiber in forum TBGL General
    Replies: 8
    Last Post: 05-08-2008, 06:06

Posting Permissions

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