There are X to md2 converter out there.
Printable View
There are X to md2 converter out there.
Hi
I use fragmotion
loading M15 models from memory is a fun thing, here is loading a textured box using :
still i don't know how to access one vertex and change its positions, colors, normals and UV values at run timeCode:Dim model(2) As m15Model
String memoryBuffer = FILE_Load(APP_SourcePath + "box.M15")
For i=1 To 2
model(i).FromMemory(memoryBuffer)
Next
while the usual M15 have many functions such as TBGL_m15SetVertexXYZ and so on.
download : code+box model+texture+m15 unitsCode: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
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
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:
I think it could result in more readable code, with less FOR/NEXTing.Code: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()
Petr
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.
Thank you Primo,
I will have a look at it :)
Petr