ArcScene: 2D scene export uses OpenGL 1.1

3825
15
10-06-2012 05:40 AM
SteffenErnst
New Contributor
Hi,

I would like to render geometry with OpenGL 2.0 which works well in ArcScene and ArcGlobe in normal view. Now the geometry should also be drawn in exported screenshots. This works well in ArcGlobe with the export function from file menu. But it doesn???t in ArcScene while using the export to 2D function, because ArcScene uses an OpenGL 1.1 context for image export.

This happens in ArcScene 10.0 and 10.1. C# is used as development language. Is there a way to get an OpenGL 2.0 context also for image export in ArcScene?
0 Kudos
15 Replies
SteffenErnst
New Contributor
Hi,

this thread describes how to get the spatial reference by casting the layer to an IGeoDataset.
http://forums.esri.com/Thread.asp?c=159&f=1707&t=223709
A ISurface has also a reference in its domain attribute, you can try this too.
pt.SpatialReference = surface.Domain.SpatialReference

I can send you my mail address as private message, but you have to enable it in your forum settings first.
0 Kudos
tianyuzhang
New Contributor
Hi,

this thread describes how to get the spatial reference by casting the layer to an IGeoDataset.
http://forums.esri.com/Thread.asp?c=159&f=1707&t=223709
A ISurface has also a reference in its domain attribute, you can try this too.
pt.SpatialReference = surface.Domain.SpatialReference

I can send you my mail address as private message, but you have to enable it in your forum settings first.


Hi,

i have send you a message.
0 Kudos
juan_marvinwirjomartono
New Contributor III
Hello,

I saw your posts, which really gave me a chance to solve my ArcScene problem. I have a problem to draw objects using OpenGL on the ArcScene view.

I usually work with ArcMap, and never used OpenGL before. So I tried to follow your codes to draw points on ArcScene using OpenGL. I created a form to choose the source layer that also contains a button to run the process. Below is the code for the button _onclick:


Public Sub RefreshView()
        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

    Private Sub btnRun_Click(sender As System.Object, e As System.EventArgs) Handles btnRun.Click


        Dim pSxDoc As ISxDocument
        pSxDoc = My.ArcScene.Application.Document
        Dim pScene As IScene
        pScene = pSxDoc.Scene
        Dim pLayer As ILayer
        Dim theLayer As String = cboLayer.Text
        pLayer = GetLayer(theLayer)

        Dim theFLayer As IFeatureLayer
        Dim theFClass As IFeatureClass
        theFLayer = pLayer
        theFClass = theFLayer.FeatureClass

        Dim theFeatCursor As IFeatureCursor
        Dim theFeature As IFeature
        theFeatCursor = theFClass.Search(Nothing, False)
        theFeature = theFeatCursor.NextFeature

        While Not theFeature Is Nothing
            Dim geom As IGeometry
            geom = theFeature.ShapeCopy
            geom.Project(pScene.SpatialReference)
            Dim thePoint As IPoint
            thePoint = geom

            GL.glPointSize(15.0F)
            GL.glColor3ub(255, 0, 0)
            GL.glBegin(GL.GL_POINTS)
            GL.glVertex3f(thePoint.X, thePoint.Y, thePoint.Z)
            GL.glEnd()

            theFeature = theFeatCursor.NextFeature
        End While

        RefreshView()
    End Sub


I am using VB, however, I tried to write exactly as what I saw in this thread. Unfortunately, when I click the run button. The result is nothing. I can only see my original layer on the arcscene view, as if I didn't click the button. Is there something wrong with my codes? Any help will be much appreciated.

Thank you very much.
0 Kudos
juan_marvinwirjomartono
New Contributor III
Hellow all,

Just for your info, I found my mistakes. Now I can draw the OpenGL point next to one of my point data in ArcScene using VB language (Visual Studio 2010).

Thank you very much for this useful thread.
0 Kudos
StanislavSmetanin
New Contributor

Hello. Sorry for disturbing, but I have a same problem and I simply don't understand a source of that problem. I tried to drawing the OpenGL point, as you can see in the code below, but it doesn't work! Sorry for my english either.

Could you share with me your VB code? Some examples? Please! I never worked with OpenGL before.

ISceneGraphEvents_Event events = axSceneControl1.SceneGraph as ISceneGraphEvents_Event;

events.AfterDraw += new ISceneGraphEvents_AfterDrawEventHandler(events_AfterDraw);

void events_AfterDraw(ISceneViewer pViewer)

        {

            ISceneControlEvents_OnMouseDownEvent events = e;

            if (events != null)

            {

                ISceneGraph pSceneGraph = axSceneControl1.SceneGraph;

                object pOwner = null, //слой

                    pObject = null; //объект, на который указывает мышь

                IPoint point = null;

                pSceneGraph.Locate(pSceneGraph.ActiveViewer, events.x, events.y, esriScenePickMode.esriScenePickFastLocation, true, out point, out pOwner, out pObject);

                if (point != null)

                {

                    IGeometry geom = point as IGeometry;

                    geom.Project(axSceneControl1.Scene.SpatialReference);

                    point = geom as IPoint;

                    Gl.glPointSize(999.0f);

                    Gl.glColor3ub(0, 0, 0);

                    Gl.glBegin(Gl.GL_POINTS);

                    Gl.glVertex3d(point.X, point.Y, point.Z);

                    Gl.glEnd();

                    Gl.glFlush();

                    axSceneControl1.Invalidate();

                }

            }       

        }

0 Kudos
StanislavSmetanin
New Contributor

Please... someone... I need help)

0 Kudos