OpenGL on ArcScene

2029
1
06-20-2013 01:52 AM
juan_marvinwirjomartono
New Contributor III
Hi all,

I try to build an arcscene add-in using VB. I have 3D point data that I open in ArcScene. What I want to do is to draw something somewhere near any of my 3D point using OpenGL. I am using tao framework and I tried these codes below. However, after I run the code, I don't see anything except my 3D points, just exactly as I don't run the code. I hope someone can find my mistake in my code so that I can fix it.

This is the code in my main add-in button:

Imports ESRI.ArcGIS.ArcScene

Public Class Button1
    Inherits ESRI.ArcGIS.Desktop.AddIns.Button

    Public Sub New()

    End Sub

    Protected Overrides Sub OnClick()
        '
        '  TODO: Sample code showing how to access button host
        '
        My.ArcScene.Application.CurrentTool = Nothing
        Dim f As Form1
        f = New Form1
        Dim mApp As ESRI.ArcGIS.Framework.IApplication
        mApp = My.ArcScene.Application
        Dim pSxDoc As ISxDocument
        pSxDoc = mApp.Document
        f.m_pSG = pSxDoc.Scene.SceneGraph
        f.flag = True
        f.Show()
    End Sub

    Protected Overrides Sub OnUpdate()
        Enabled = My.ArcScene.Application IsNot Nothing
    End Sub
End Class


And I have a windows form which only contains a button (which is useless for now). And below is the code of that form:

Option Explicit On
Imports ESRI.ArcGIS.Analyst3D
Imports ESRI.ArcGIS.ArcScene
Imports Tao.OpenGl

Public Class Form1
    Public WithEvents m_pSG As SceneGraph

    Public flag As Boolean

    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        flag = Not flag
    End Sub


    Private Sub m_pSG_AfterDraw(pViewer As ESRI.ArcGIS.Analyst3D.ISceneViewer) Handles m_pSG.AfterDraw
        'If flag = True Then
        Gl.glEnable(Gl.GL_LIGHTING)
        Gl.glEnable(Gl.GL_LIGHT0)
        Gl.glPointSize(150.0F) 'I hope this point size is big enough to see
        Gl.glBegin(Gl.GL_POINTS)  'my plan is to draw something to the arcscene view. I am trying to begin with a point.
        Gl.glColor4d(1.0, 0.0, 0.0, 1.0)
        Gl.glVertex3d(441966.202158, 563235.610666, 93)   'my expected coordinate where I want to draw the point. (x,y,z)

        Gl.glEnd()
        Gl.glFinish()
        'End If
        Dim pSxDoc As ISxDocument
        pSxDoc = My.ArcScene.Application.Document
        pSxDoc.Scene.SceneGraph.Invalidate(pSxDoc.Scene.SceneGraph.ActiveViewer, True, True)
        pSxDoc.Scene.SceneGraph.RefreshViewers()
    End Sub
End Class


On my first attempt, in this code I am trying to draw a simple point with a certain size. Please, if you know something to make that object appear on the arcscene view, your help will be much appreciated.

Thank you very much.
0 Kudos
1 Reply
juan_marvinwirjomartono
New Contributor III
Solved. Thanks.
0 Kudos