Page 3 of 3 FirstFirst 123
Results 21 to 27 of 27

Thread: M15 - reimplementation via GBuffers

  1. #21
    There are X to md2 converter out there.

  2. #22
    Hi

    I use fragmotion

  3. #23
    loading M15 models from memory is a fun thing, here is loading a textured box using :
    Dim model(2) As m15Model
    
    String memoryBuffer = FILE_Load(APP_SourcePath + "box.M15") 
    For i=1 To 2
    model(i).FromMemory(memoryBuffer) 
    Next
    
    still i don't know how to access one vertex and change its positions, colors, normals and UV values at run time
    while the usual M15 have many functions such as TBGL_m15SetVertexXYZ and so on.

    Uses "tbgl"
    
    #INCLUDE "m15Model/m15Model.tbasicu" ' -- can be just m15Model.tbasicu, depends where your code is :]
    
    Long i, wireframe
    
    Single y, x, z
    
    DWord hWnd = TBGL_CreateWindowEx("press 'W' for wire/solid Frame .... press ESC to quit", 800, 600, 32, 0) 
    TBGL_ShowWindow
    
    Dim model(2) As m15Model
    
    String memoryBuffer = FILE_Load(APP_SourcePath + "box.M15") 
    For i=1 To 2
    model(i).FromMemory(memoryBuffer) 
    Next
    
    TBGL_LoadTexture APP_SourcePath+"color.bmp", 1, %TBGL_TEX_MIPMAP    ' Loads texture as #1, with high quality
    TBGL_UseTexturing %TRUE           ' I want to use textures
    TBGL_BindTexture 1    
      
    TBGL_ResetKeyState
    
    TBGL_UseLighting TRUE
    TBGL_UseLightSource %GL_LIGHT0, 1 
    
    
    While TBGL_IsWindow(hWnd)
    If TBGL_GetWindowKeyOnce( hWnd, %VK_W) Then
    wireframe = Not wireframe
    TBGL_PolygonLook IIf(wireframe, %GL_LINE, %GL_FILL) 
    End If
    
    TBGL_ClearFrame
    TBGL_Camera 0, 40, 60, 0, 0, 0
    
    TBGL_Rotate GetTickCount/40 , 0, 1, 0
    
    TBGL_Translate  -10, 0, 0.7 
    model(1).render    
    TBGL_Translate  20, 0, 0.7 
    model(2).render
    
    TBGL_DrawFrame
    
    If TBGL_GetWindowKeyState( hWnd, %VK_ESCAPE) Then Exit While
    
    Wend
    
    TBGL_DestroyWindow
    
    download : code+box model+texture+m15 units
    Attached Files Attached Files
    Last edited by primo; 01-03-2017 at 14:09.

  4. #24
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,128
    Rep Power
    732
    Hi Primo,

    what a joy to see you using the header I will think about how I can add this direct manipulation to the unit, stay tuned!


    Petr
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

  5. #25
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,128
    Rep Power
    732
    Primo,

    I was thinking how to improve current approach, how to do batched changes more efficientely.
    This is what I came up with, not yet implemented:
    dim vertices as m15VertexEnumerator(model)
    
    model.BeginWrite()
    
      model.SetVertexPos(vertices.first, 1, 2, 3) ' -- Sets coordinates of 1, 2, 3 to the first vertex
      model.SetVertexColor(vertices.first, 255, 255, 255) ' -- Sets white color to the first vertex
    
      model.SetVertexColor(vertices.firstPolygon, 255, 255, 255) ' -- Sets white color to vertices of the first polygon
    
      model.SetVertexColor(vertices.nthPolygon(2), 255, 255, 255) ' -- Sets white color to vertices of the second polygon
    
      model.SetVertexColor(vertices.all, 255, 255, 255) ' -- Sets white color to all vertices
    
    model.EndWrite()
    
    I think it could result in more readable code, with less FOR/NEXTing.


    Petr
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

  6. #26
    Hi Petr
    seems goods choices, i suggest also something like this:
    model.SetVertexPos(vertices.nthVertex(37), 20, 50, -10)
    will change the vertex number 37 coordinates to 20, 50, -10
    if everything is okay, then i think adding it to the official thinbasic distribution will be great. like adding before the StringBuilder .
    regards

    edit: model.SetVertexPos(vertices.nthPolygon(6), 10,30, 10)
    could it be possible !! in which the polygon coordinates is the coord of its center.
    it is like : model.SetVertexColor(vertices.nthPolygon(2), 255, 255, 255)

    edit2: i think model.SetVertexPos(vertices.nthPolygon(6), 10,30, 10) is not necessary, since it is a programmer task to get every polygon vertices and do what he wants.
    Last edited by primo; 12-03-2017 at 16:05.

  7. #27
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,128
    Rep Power
    732
    Thank you Primo,

    I will have a look at it


    Petr
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

Page 3 of 3 FirstFirst 123

Similar Threads

  1. How to combine GBuffers & Entities?
    By ReneMiner in forum TBGL General
    Replies: 9
    Last Post: 16-01-2018, 08:56
  2. glDrawArrays example + GBuffers example
    By primo in forum TBGL General
    Replies: 1
    Last Post: 21-11-2015, 23:47
  3. The silence inside the fractal - GBuffers (how many may be used ?)
    By RobbeK in forum TBGL Scripts and Projects
    Replies: 35
    Last Post: 24-01-2014, 12:18
  4. Preview: GBuffers for TBGL
    By Petr Schreiber in forum TBGL module by Petr Schreiber
    Replies: 11
    Last Post: 04-03-2010, 11:33

Members who have read this thread: 0

There are no members to list at the moment.

Posting Permissions

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