Android Question 3D Tin Model using OpenGL

Terradrones

Active Member
I have a TIN Model consisting of Triangles as defined by their Vertexes. I would like to display this as a 3D Model using OpenGL, but my code is full of errors. If somebody could please give me a push in the right direction. Here is my code:

B4X:
Sub Render3D
    If GlSV.DeviceAPILevel < 8 Then
        MsgboxAsync("OpenGL Is Not Supported On This Device", "OpenGL Error")
        Panels
        Panel1.Visible=True
    End If
    Panels
    Panel6.Visible = True
    Pnl3DView.Visible = True
    ProgressDialogShow("Generating 3D Model...")
    Sleep(0)
    CalculateScalingFactors
    GetVertices

    GlSV.Initialize2(GlSV.RENDERMODE_WHEN_DIRTY, "glsv", 16, 0)
    Pnl3DView.AddView(GlSV, 0, 0, Pnl3DView.Width, Pnl3DView.Height)
    ProgressDialogHide
End Sub

Sub Butt3_Click
'    Timer1.Enabled = False
    Panels
    Panel1.Visible=True
End Sub

Sub GLSV_Draw(gl As GL2)
    Try
        gl.glClear(Bit.Or(gl.GL_COLOR_BUFFER_BIT, gl.GL_DEPTH_BUFFER_BIT))
'        gl.glLoadIdentity()
'        gl.glTranslatef(0, 0, -5)
'        gl.glRotatef(EyeAngle * (180 / 3.14159), 0, 1, 0)
        
        DrawTINModel(gl)
    Catch
        Log(LastException)
    End Try
End Sub

Sub glsv_SurfaceChanged(gl As GL2, width As Int, height As Int)
    Log("Changed")
    Try
        gl.glViewport(0, 0, width, height)
        Dim ratio As Float = width / height
        gl.gluPerspective(45, ratio, 1, 100)
    Catch
        Log(LastException)
    End Try
End Sub
    
Sub glsv_SurfaceCreated(gl As GL2)
    Log("Created")
    Try
        gl.glClearColor(0, 0, 0, 1)
        gl.glEnable(gl.GL_DEPTH_TEST)
        gl.glDepthFunc(gl.GL_LESS)
    Catch
        Log(LastException)
    End Try
End Sub

Sub Timer1_Tick
    EyeAngle = EyeAngle + 0.1
    If EyeAngle > (2 * 3.14159) Then EyeAngle = EyeAngle - (2 * 3.14159)
    GlSV.RequestRender
End Sub

Sub GetVertices
    Dim i As Int
    
    i=0
    vertixes.Initialize
    Do While i<=CGlobals.MaxTins
        Y1=ConvertPhysicToCADX(CGlobals.Tin3D(i).East)
        X1=ConvertPhysicToCADY(CGlobals.Tin3D(i).North)
        vertixes.Add(Array As Float(X1, Y1, CGlobals.Tin3D(i).Elev)) ' x, y, height
        
        Y1=ConvertPhysicToCADX(CGlobals.Tin3D(i).East1)
        X1=ConvertPhysicToCADY(CGlobals.Tin3D(i).North1)
        vertixes.Add(Array As Float(X1, Y1, CGlobals.Tin3D(i).Elev1)) ' x, y, he
        
        Y1=ConvertPhysicToCADX(CGlobals.Tin3D(i).East2)
        X1=ConvertPhysicToCADY(CGlobals.Tin3D(i).North2)
        vertixes.Add(Array As Float(X1, Y1, CGlobals.Tin3D(i).Elev2)) ' x, y, he
        i=i+1
    Loop
    
    MinX=PntMinX
    MinY=PntMinY
    MaxX=PntMaxX
    MaxY=PntMaxY
    MinZ=CGlobals.ZMinCont
    MaxZ=CGlobals.ZMaxCont
    
End Sub

Sub CalculateScalingFactors
    ' Determine the range of your world coordinates
    Dim rangeX As Float = PntMaxX - PntMinX
    Dim rangeY As Float = PntMaxY - PntMinY
    Dim rangeZ As Float = CGlobals.ZMaxCont- CGlobals.ZMinCont

    ' Determine the dimensions of your screen or viewport
    Dim screenWidth As Float = Pnl3DView.Width
    Dim screenHeight As Float = Pnl3DView.Height

    ' Calculate the scaling factors
    Dim scaleFactorX As Float = screenWidth / rangeX
    Dim scaleFactorY As Float = screenHeight / rangeY

    ' Use the minimum of the two scaling factors to maintain aspect ratio
    Dim scaleFactor As Float = Min(scaleFactorX, scaleFactorY)

    ' Apply the same scaling factor to all axes
    ScaleX1 = scaleFactor
    ScaleY1 = scaleFactor
    ScaleZ1 = scaleFactor ' Assuming Z scaling is proportional to X and Y
End Sub

Sub DrawTINModel(gl As GL2)

'    If vertixes.Size < 3 Then
'        Log("Not enough vertices to draw a triangle")
'        Return
'    End If
'
'    Try
'        Dim jo As JavaObject = gl
'        jo.RunMethod("glEnableClientState", Array(gl.GL_VERTEX_ARRAY)) ' Enable vertex array
'
'        ' Define vertex pointer
'        jo.RunMethod("glVertexPointer", Array(3, gl.GL_FLOAT, 0, vertixes)) ' Assuming vertices is a Float array
'
'        ' Draw the vertices as triangles
'        jo.RunMethod("glDrawArrays", Array(gl.GL_TRIANGLES, 0, vertixes.Size / 3))
'
'        jo.RunMethod("glDisableClientState", Array(gl.GL_VERTEX_ARRAY)) ' Disable vertex array
'    Catch
'        Log("Exception during drawing: " & LastException)
'    End Try
End Sub

And my screen is black.

Thanks
Michael
 

MasterGy

Member
I have a TIN Model consisting of Triangles as defined by their Vertexes. I would like to display this as a 3D Model using OpenGL, but my code is full of errors. If somebody could please give me a push in the right direction. Here is my code:

B4X:
Sub Render3D
    If GlSV.DeviceAPILevel < 8 Then
        MsgboxAsync("OpenGL Is Not Supported On This Device", "OpenGL Error")
        Panels
        Panel1.Visible=True
    End If
    Panels
    Panel6.Visible = True
    Pnl3DView.Visible = True
    ProgressDialogShow("Generating 3D Model...")
    Sleep(0)
    CalculateScalingFactors
    GetVertices

    GlSV.Initialize2(GlSV.RENDERMODE_WHEN_DIRTY, "glsv", 16, 0)
    Pnl3DView.AddView(GlSV, 0, 0, Pnl3DView.Width, Pnl3DView.Height)
    ProgressDialogHide
End Sub

Sub Butt3_Click
'    Timer1.Enabled = False
    Panels
    Panel1.Visible=True
End Sub

Sub GLSV_Draw(gl As GL2)
    Try
        gl.glClear(Bit.Or(gl.GL_COLOR_BUFFER_BIT, gl.GL_DEPTH_BUFFER_BIT))
'        gl.glLoadIdentity()
'        gl.glTranslatef(0, 0, -5)
'        gl.glRotatef(EyeAngle * (180 / 3.14159), 0, 1, 0)
       
        DrawTINModel(gl)
    Catch
        Log(LastException)
    End Try
End Sub

Sub glsv_SurfaceChanged(gl As GL2, width As Int, height As Int)
    Log("Changed")
    Try
        gl.glViewport(0, 0, width, height)
        Dim ratio As Float = width / height
        gl.gluPerspective(45, ratio, 1, 100)
    Catch
        Log(LastException)
    End Try
End Sub
   
Sub glsv_SurfaceCreated(gl As GL2)
    Log("Created")
    Try
        gl.glClearColor(0, 0, 0, 1)
        gl.glEnable(gl.GL_DEPTH_TEST)
        gl.glDepthFunc(gl.GL_LESS)
    Catch
        Log(LastException)
    End Try
End Sub

Sub Timer1_Tick
    EyeAngle = EyeAngle + 0.1
    If EyeAngle > (2 * 3.14159) Then EyeAngle = EyeAngle - (2 * 3.14159)
    GlSV.RequestRender
End Sub

Sub GetVertices
    Dim i As Int
   
    i=0
    vertixes.Initialize
    Do While i<=CGlobals.MaxTins
        Y1=ConvertPhysicToCADX(CGlobals.Tin3D(i).East)
        X1=ConvertPhysicToCADY(CGlobals.Tin3D(i).North)
        vertixes.Add(Array As Float(X1, Y1, CGlobals.Tin3D(i).Elev)) ' x, y, height
       
        Y1=ConvertPhysicToCADX(CGlobals.Tin3D(i).East1)
        X1=ConvertPhysicToCADY(CGlobals.Tin3D(i).North1)
        vertixes.Add(Array As Float(X1, Y1, CGlobals.Tin3D(i).Elev1)) ' x, y, he
       
        Y1=ConvertPhysicToCADX(CGlobals.Tin3D(i).East2)
        X1=ConvertPhysicToCADY(CGlobals.Tin3D(i).North2)
        vertixes.Add(Array As Float(X1, Y1, CGlobals.Tin3D(i).Elev2)) ' x, y, he
        i=i+1
    Loop
   
    MinX=PntMinX
    MinY=PntMinY
    MaxX=PntMaxX
    MaxY=PntMaxY
    MinZ=CGlobals.ZMinCont
    MaxZ=CGlobals.ZMaxCont
   
End Sub

Sub CalculateScalingFactors
    ' Determine the range of your world coordinates
    Dim rangeX As Float = PntMaxX - PntMinX
    Dim rangeY As Float = PntMaxY - PntMinY
    Dim rangeZ As Float = CGlobals.ZMaxCont- CGlobals.ZMinCont

    ' Determine the dimensions of your screen or viewport
    Dim screenWidth As Float = Pnl3DView.Width
    Dim screenHeight As Float = Pnl3DView.Height

    ' Calculate the scaling factors
    Dim scaleFactorX As Float = screenWidth / rangeX
    Dim scaleFactorY As Float = screenHeight / rangeY

    ' Use the minimum of the two scaling factors to maintain aspect ratio
    Dim scaleFactor As Float = Min(scaleFactorX, scaleFactorY)

    ' Apply the same scaling factor to all axes
    ScaleX1 = scaleFactor
    ScaleY1 = scaleFactor
    ScaleZ1 = scaleFactor ' Assuming Z scaling is proportional to X and Y
End Sub

Sub DrawTINModel(gl As GL2)

'    If vertixes.Size < 3 Then
'        Log("Not enough vertices to draw a triangle")
'        Return
'    End If
'
'    Try
'        Dim jo As JavaObject = gl
'        jo.RunMethod("glEnableClientState", Array(gl.GL_VERTEX_ARRAY)) ' Enable vertex array
'
'        ' Define vertex pointer
'        jo.RunMethod("glVertexPointer", Array(3, gl.GL_FLOAT, 0, vertixes)) ' Assuming vertices is a Float array
'
'        ' Draw the vertices as triangles
'        jo.RunMethod("glDrawArrays", Array(gl.GL_TRIANGLES, 0, vertixes.Size / 3))
'
'        jo.RunMethod("glDisableClientState", Array(gl.GL_VERTEX_ARRAY)) ' Disable vertex array
'    Catch
'        Log("Exception during drawing: " & LastException)
'    End Try
End Sub

And my screen is black.

Thanks
Michael
I'm happy to help with opengl, but unfortunately I don't understand your code. If there was only enough in your code that generates the lines or points, so it creates the graphic data, then I can try to build a renderer on top of it.
 
Upvote 0

Terradrones

Active Member
Hi MasterGy

Each Triangle of the TIN Model is formatted as such in the file:

X1,Y1,Z1 & X2,Y2,Z2 & X3,Y3,Z3 & Area

These represent the vertexes of each Triangle. The Area I use to determine in which Triangle the GPS or Prism Pole is held or if it is outside the TIN Model area. If it is inside a Triangle, I then calculate the theorical height what it must be using the coordinates of the vertexes and comparing that to the actual elevation.

I would like to present this TIN Model in a 3D view where the Surveyor can rotate the Model and also zoom in and out.

It does not really have any practical use, but it would be a nice feature in my Surveying program.

The module in the Ceaser program is called "Stock" and it is used to calculate the volume, plane area and slope area of a Stockpile that has been surveyed. I have also added "Height" shading to it.

Thanks
Michael
 
Upvote 0

MasterGy

Member
Hello!

I have prepared a possible solution.

All you have to do is upload your triangles in the activity with: 'ADD_TRIANGLE'

You have to enter 12 parameters.

x0,y0,z0,x1,y1,z1,x2,y2,z2 ,R,G,B

The 3 coordinate points of the triangle and its rgb color.

Make sure the coordinate points fall between -1 and 1, that's how it's set to display correctly.

In process_globals, 'dim triangle(200,12)' . if you have more than 200 triangles, set it as large as possible.

The program currently creates 10 randomly placed triangles, you can rotate and zoom.






triangles:
#Region  Project Attributes
    #ApplicationLabel: B4A Example
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: landscape
    #CanInstallToExternalStorage: False
#End Region

#Region  Activity Attributes
    #FullScreen: true
    #IncludeTitle: false
#End Region

Sub Process_Globals
    Dim OpenGL_timer As Timer
    Dim triangle_c As Int
    Dim triangle(200,12) As Float '012-x0y0z0 345-x1y1z1 678-x2y2z2 ,9,10,11 RGB
End Sub

Sub Globals
    Dim OpenGL As GLSurfaceView
    Dim seekbar As SeekBar
    Dim touchpanel As Panel
    Dim touchpanel_data(10) As Float
    Dim lbl As Label
    Dim zoom_distance As Float
End Sub

Sub Activity_Create(FirstTime As Boolean)


    
    'touchpanel
    touchpanel.Initialize("TouchPanel")
    Activity.AddView(touchpanel,  0,0,100%x,100%y)
    
    'opengl, opengltimer
    OpenGL.Initialize(OpenGL.RENDERMODE_WHEN_DIRTY, "opengl")
    Activity.AddView(OpenGL, 0,0,100%x,100%y)
    OpenGL_timer.Initialize("opengl_render",60)
    OpenGL_timer.Enabled = True

    'label   
    lbl.Initialize("lbl") ' Az "lbl" az események azonosítására szolgál
    lbl.TextSize = 20
    lbl.TextColor = Colors.argb(200,255,255,255)
    lbl.Color = Colors.argb(100,255,0,0)
    Activity.AddView(lbl, 0, 0, Activity.width, 50dip)

    'seekbar
    seekbar.Initialize("seekbar")
    seekbar.Max = 100
    seekbar.Value = 50
    Activity.AddView(seekbar, 0, Activity.Height - 50dip, Activity.Width, 50dip) ' SeekBar elhelyezése az alján




    For t = 0 To 10
    add_triangle(randpos,randpos,randpos,randpos,randpos,randpos,randpos,randpos,randpos,Rnd(0,150),Rnd(0,150),Rnd(0,150))
    Next

End Sub

Sub randpos As Float
    Return  Rnd(0,1000)/1000-.5
    
End Sub

Sub add_triangle(x0 As Float,y0 As Float,z0 As Float,x1 As Float,y1 As Float,z1 As Float,x2 As Float,y2 As Float,z2 As Float,colr As Float,colg As Float,colb As Float)
    triangle(triangle_c,0) = x0
    triangle(triangle_c,1) = y0
    triangle(triangle_c,2) = z0
    triangle(triangle_c,3) = x1
    triangle(triangle_c,4) = y1
    triangle(triangle_c,5) = z1
    triangle(triangle_c,6) = x2
    triangle(triangle_c,7) = y2
    triangle(triangle_c,8) = z2
    triangle(triangle_c,9) = colr/255
    triangle(triangle_c,10) = colg/255
    triangle(triangle_c,11) = colb/255
    triangle_c = triangle_c+1
    
End Sub

Sub TouchPanel_Touch (Action As Int, X As Float, Y As Float)
    
    If Action = Activity.ACTION_MOVE  Then
        touchpanel_data(2) = touchpanel_data(2)+(touchpanel_data(0)-x)*.15
        touchpanel_data(3) = touchpanel_data(3)+(touchpanel_data(1)-y)*.15
    End If

    touchpanel_data(0) = X
    touchpanel_data(1) = y
End Sub

Sub opengl_render_tick
    OpenGL.RequestRender
    lbl.Text = "ANG1:"& NumberFormat(touchpanel_data(2), 1, 1) &"  ANG2:"  &   NumberFormat(touchpanel_data(3), 1, 1) & "  DISTANCE:"& NumberFormat(Abs(zoom_distance), 1, 1)
    lbl.Invalidate
End Sub




Sub opengl_draw(gl As GL1)
    
    
    gl.glDisableClientState(gl.GL_VERTEX_ARRAY)
    gl.glDisableClientState(gl.GL_TEXTURE_COORD_ARRAY)
    gl.glDisableClientState(gl.GL_NORMAL_ARRAY)


    
    
    gl.glClearColor(.8, .8, .8, 1)
    gl.glClear(Bit.Or(gl.GL_COLOR_BUFFER_BIT, gl.GL_DEPTH_BUFFER_BIT))

    gl.glEnable(gl.GL_NORMALIZE)

    gl.glLoadIdentity
    
    gl.glTranslatef(0,0,zoom_distance)
    gl.glrotatef(-touchpanel_data(3),1,0,0)
    gl.glrotatef(-touchpanel_data(2),0,1,0)
    
    
    
    
    gl.glFrontFace(gl.GL_CCW)
    gl.glEnableClientState(gl.GL_VERTEX_ARRAY)
    gl.glEnableClientState(gl.GL_VERTEX_ARRAY)

    gl.glEnable(gl.GL_DEPTH_TEST)
    gl.glDepthFunc(gl.GL_LEQUAL)
    gl.glDepthMask(True)
    gl.glDisable(gl.GL_BLEND)
    
    gl.glPushMatrix
    
    

    Dim vertices(9) As Float
    For at = 0 To triangle_c-1
            
        For t = 0 To 8:vertices(t) = triangle(at,t):Next
            gl.glVertexPointerf(3,  vertices)
            gl.glColor4f(triangle(at,9),triangle(at,10),triangle(at,11), 1) ' RGBA = Red    ' Set the color to red for the triangle
             gl.glDrawArrays(gl.GL_TRIANGLES, 0, 3)
        Next
        
    gl.glPopMatrix
    gl.glDisableClientState(gl.GL_VERTEX_ARRAY)

End Sub

Sub opengl_SurfaceChanged(gl As GL1, width As Int, height As Int)
    
    gl.glViewport(0, 0, width, height)
    gl.glMatrixMode(gl.GL_PROJECTION)
    gl.gluPerspective(60,width/height,0.01,6)
    gl.glMatrixMode(gl.GL_MODELVIEW)

    
End Sub


Sub SeekBar_ValueChanged (Value As Int, UserChanged As Boolean)
    zoom_distance = -(100-Value)*.05
End Sub
 
Upvote 0

Johan Schoeman

Expert
Licensed User
Longtime User
It might be worthwhile working through this thread starting at post #1. Perhaps you have already seen it but in case you have not. A great library by @agraham

 
Upvote 0

Terradrones

Active Member
Hello!

I have prepared a possible solution.

All you have to do is upload your triangles in the activity with: 'ADD_TRIANGLE'

You have to enter 12 parameters.

x0,y0,z0,x1,y1,z1,x2,y2,z2 ,R,G,B

The 3 coordinate points of the triangle and its rgb color.

Make sure the coordinate points fall between -1 and 1, that's how it's set to display correctly.

In process_globals, 'dim triangle(200,12)' . if you have more than 200 triangles, set it as large as possible.

The program currently creates 10 randomly placed triangles, you can rotate and zoom.






triangles:
#Region  Project Attributes
    #ApplicationLabel: B4A Example
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: landscape
    #CanInstallToExternalStorage: False
#End Region

#Region  Activity Attributes
    #FullScreen: true
    #IncludeTitle: false
#End Region

Sub Process_Globals
    Dim OpenGL_timer As Timer
    Dim triangle_c As Int
    Dim triangle(200,12) As Float '012-x0y0z0 345-x1y1z1 678-x2y2z2 ,9,10,11 RGB
End Sub

Sub Globals
    Dim OpenGL As GLSurfaceView
    Dim seekbar As SeekBar
    Dim touchpanel As Panel
    Dim touchpanel_data(10) As Float
    Dim lbl As Label
    Dim zoom_distance As Float
End Sub

Sub Activity_Create(FirstTime As Boolean)


   
    'touchpanel
    touchpanel.Initialize("TouchPanel")
    Activity.AddView(touchpanel,  0,0,100%x,100%y)
   
    'opengl, opengltimer
    OpenGL.Initialize(OpenGL.RENDERMODE_WHEN_DIRTY, "opengl")
    Activity.AddView(OpenGL, 0,0,100%x,100%y)
    OpenGL_timer.Initialize("opengl_render",60)
    OpenGL_timer.Enabled = True

    'label  
    lbl.Initialize("lbl") ' Az "lbl" az események azonosítására szolgál
    lbl.TextSize = 20
    lbl.TextColor = Colors.argb(200,255,255,255)
    lbl.Color = Colors.argb(100,255,0,0)
    Activity.AddView(lbl, 0, 0, Activity.width, 50dip)

    'seekbar
    seekbar.Initialize("seekbar")
    seekbar.Max = 100
    seekbar.Value = 50
    Activity.AddView(seekbar, 0, Activity.Height - 50dip, Activity.Width, 50dip) ' SeekBar elhelyezése az alján




    For t = 0 To 10
    add_triangle(randpos,randpos,randpos,randpos,randpos,randpos,randpos,randpos,randpos,Rnd(0,150),Rnd(0,150),Rnd(0,150))
    Next

End Sub

Sub randpos As Float
    Return  Rnd(0,1000)/1000-.5
   
End Sub

Sub add_triangle(x0 As Float,y0 As Float,z0 As Float,x1 As Float,y1 As Float,z1 As Float,x2 As Float,y2 As Float,z2 As Float,colr As Float,colg As Float,colb As Float)
    triangle(triangle_c,0) = x0
    triangle(triangle_c,1) = y0
    triangle(triangle_c,2) = z0
    triangle(triangle_c,3) = x1
    triangle(triangle_c,4) = y1
    triangle(triangle_c,5) = z1
    triangle(triangle_c,6) = x2
    triangle(triangle_c,7) = y2
    triangle(triangle_c,8) = z2
    triangle(triangle_c,9) = colr/255
    triangle(triangle_c,10) = colg/255
    triangle(triangle_c,11) = colb/255
    triangle_c = triangle_c+1
   
End Sub

Sub TouchPanel_Touch (Action As Int, X As Float, Y As Float)
   
    If Action = Activity.ACTION_MOVE  Then
        touchpanel_data(2) = touchpanel_data(2)+(touchpanel_data(0)-x)*.15
        touchpanel_data(3) = touchpanel_data(3)+(touchpanel_data(1)-y)*.15
    End If

    touchpanel_data(0) = X
    touchpanel_data(1) = y
End Sub

Sub opengl_render_tick
    OpenGL.RequestRender
    lbl.Text = "ANG1:"& NumberFormat(touchpanel_data(2), 1, 1) &"  ANG2:"  &   NumberFormat(touchpanel_data(3), 1, 1) & "  DISTANCE:"& NumberFormat(Abs(zoom_distance), 1, 1)
    lbl.Invalidate
End Sub




Sub opengl_draw(gl As GL1)
   
   
    gl.glDisableClientState(gl.GL_VERTEX_ARRAY)
    gl.glDisableClientState(gl.GL_TEXTURE_COORD_ARRAY)
    gl.glDisableClientState(gl.GL_NORMAL_ARRAY)


   
   
    gl.glClearColor(.8, .8, .8, 1)
    gl.glClear(Bit.Or(gl.GL_COLOR_BUFFER_BIT, gl.GL_DEPTH_BUFFER_BIT))

    gl.glEnable(gl.GL_NORMALIZE)

    gl.glLoadIdentity
   
    gl.glTranslatef(0,0,zoom_distance)
    gl.glrotatef(-touchpanel_data(3),1,0,0)
    gl.glrotatef(-touchpanel_data(2),0,1,0)
   
   
   
   
    gl.glFrontFace(gl.GL_CCW)
    gl.glEnableClientState(gl.GL_VERTEX_ARRAY)
    gl.glEnableClientState(gl.GL_VERTEX_ARRAY)

    gl.glEnable(gl.GL_DEPTH_TEST)
    gl.glDepthFunc(gl.GL_LEQUAL)
    gl.glDepthMask(True)
    gl.glDisable(gl.GL_BLEND)
   
    gl.glPushMatrix
   
   

    Dim vertices(9) As Float
    For at = 0 To triangle_c-1
           
        For t = 0 To 8:vertices(t) = triangle(at,t):Next
            gl.glVertexPointerf(3,  vertices)
            gl.glColor4f(triangle(at,9),triangle(at,10),triangle(at,11), 1) ' RGBA = Red    ' Set the color to red for the triangle
             gl.glDrawArrays(gl.GL_TRIANGLES, 0, 3)
        Next
       
    gl.glPopMatrix
    gl.glDisableClientState(gl.GL_VERTEX_ARRAY)

End Sub

Sub opengl_SurfaceChanged(gl As GL1, width As Int, height As Int)
   
    gl.glViewport(0, 0, width, height)
    gl.glMatrixMode(gl.GL_PROJECTION)
    gl.gluPerspective(60,width/height,0.01,6)
    gl.glMatrixMode(gl.GL_MODELVIEW)

   
End Sub


Sub SeekBar_ValueChanged (Value As Int, UserChanged As Boolean)
    zoom_distance = -(100-Value)*.05
End Sub
Hi MasterGy, thank you very much for that. I am in Jefferies Bay at the moment, but I am driving back to Paarl tomorrow. I will give it a try on Tuesday.
 
Upvote 0
Top