ArcScene: 2D scene export uses OpenGL 1.1

3778
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
tianyuzhang
New Contributor
Hi,SOrry that i can't help you .
i'am using opengl in scenecontrol recently ,i'am wondering how could you canvert a  coordinate in map(geographic coordinates) to a coordinate in opengl ?

waiting for your respond...
0 Kudos
SteffenErnst
New Contributor
Hi,

this can be done with the function GeographicToGeocentric, as described on this page
http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#/How_to_draw_a_geographi...
0 Kudos
tianyuzhang
New Contributor
Hi,

this can be done with the function GeographicToGeocentric, as described on this page
http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#/How_to_draw_a_geographi...



Hi ,DO you know how to enforce the function" GeographicTO geocentric " in the scenecontrol ?Or would you tell me how to convert the geographic to geocentric coordinates in scenecontrol ?
0 Kudos
SteffenErnst
New Contributor
Hi,
I use GeographicToGeocentric only in ArcGlobe, sorry for my misleading answer. In ArcScene, I just project my points to the spatial reference of the scene and pass the x- and y-coordinate to OpenGL for drawing.

IGeometry geom = feature.ShapeCopy;
geom.Project(m_sceneHookHelper.Scene.SpatialReference);
IPoint point = geom as IPoint;

GL.glPointSize(15.0f);
GL.glColor3ub(255, 0, 0);
GL.glBegin(GL.GL_POINTS);
GL.glVertex3f((float)point.X, (float)point.Y, (float)0.0);
GL.glEnd();
0 Kudos
tianyuzhang
New Contributor
Hi,
I use GeographicToGeocentric only in ArcGlobe, sorry for my misleading answer. In ArcScene, I just project my points to the spatial reference of the scene and pass the x- and y-coordinate to OpenGL for drawing.

IGeometry geom = feature.ShapeCopy;
geom.Project(m_sceneHookHelper.Scene.SpatialReference);
IPoint point = geom as IPoint;

GL.glPointSize(15.0f);
GL.glColor3ub(255, 0, 0);
GL.glBegin(GL.GL_POINTS);
GL.glVertex3f((float)point.X, (float)point.Y, (float)0.0);
GL.glEnd();



hi�?Very appreciate for your answer!! But i still have  a  question ,i add a  raster layer into my application,just like that.
[ATTACH=CONFIG]20340[/ATTACH]

1. now i think i can't use your method ?
2.i found there is a "feature" in your code ,maybe  it's useless in my application ?
3.So, how could i make  it ?  (i just know how to get the points' coordinates in the map(latitude,longtitude) ) . And the height of the point is important for i want to draw something along the terrain.

at last ,i have to say thank you very much.cause i'm a  foreigner,can't speak english very well ,so ,just forgive me ...
0 Kudos
SteffenErnst
New Contributor
Hi,

You�??re welcome, I understand your English very well.
I think you can use my method. In my application the features are points from a shapefile, but your point coordinates should do fine as well. In case a terrain is loaded, I get the height of a point in ArcScene like that:

ISurface surface = �?�;
double height = surface.GetElevation(point) * surface.ZFactor;


The surface I use is assigned to the shapefile layer, I guess you have already a reference to your terrain. The height can passed as z-coordinate to OpenGL:

GL.glVertex3f((float) point.X, (float) point.Y, (float) height);
0 Kudos
tianyuzhang
New Contributor
Hi,

You�??re welcome, I understand your English very well.
I think you can use my method. In my application the features are points from a shapefile, but your point coordinates should do fine as well. In case a terrain is loaded, I get the height of a point in ArcScene like that:

ISurface surface = �?�;
double height = surface.GetElevation(point) * surface.ZFactor;


The surface I use is assigned to the shapefile layer, I guess you have already a reference to your terrain. The height can passed as z-coordinate to OpenGL:

GL.glVertex3f((float) point.X, (float) point.Y, (float) height);



hi,
sorry about diturbing you again and again ...

i have  get the height in your method ,but when i pass the point to  OpenGL. there is nothing on the screen...

here is my code , i guess there is something wrong happened when i define the point.

[ATTACH=CONFIG]20356[/ATTACH]

wiould you help me have a check ?

In my application , i need to input the point coordinates(which i will draw by OpenGL) from outside,so i pay so much attention to the coordinate,  meanwhile , in my opinion,the coordinate system of the layer  have loaded may have some influences on drawing when i pass the x- y- z- to OpenGL.Because when i load another layer,i get the coordinate like this
[ATTACH=CONFIG]20357[/ATTACH]

unfortunately, the OpenGL did't works

hoping for your answer , thanks again!
0 Kudos
SteffenErnst
New Contributor
Hi,

I think you have to set the right spatial reference after setting the point coordinates and then project it to the reference of the scene.

pt.SpatialReference = layer.SpatialReference;
pt.Project(m_sceneHookHelper.Scene.SpatialReference);
0 Kudos
tianyuzhang
New Contributor
Hi,

I think you have to set the right spatial reference after setting the point coordinates and then project it to the reference of the scene.

pt.SpatialReference = layer.SpatialReference;
pt.Project(m_sceneHookHelper.Scene.SpatialReference);



hi,
Thanks for your answer ,i noticed that the  spatialreference property in   Ilayer and IFeaturelayer is writeonly,

   
    Public RasterLayer As IRasterLayer
    Public lyr As ILayer
   
    lyr = GetLayer(m_pDEMname)
    RasterLayer = CType(lyr, IRasterLayer)

    Private Function GetLayer(ByVal name As String) As ILayer   

        'Dim layer As ILayer

        For i As Integer = 0 To m_pScene.LayerCount - 1

            If m_pScene.Layer(i).Name = name Then
                Return m_pScene.Layer(i)
            End If

        Next

        Return Nothing

    End Function  


when i use lyr.spatialrefere or rasterlayer.spatialreference,all can't assign to pt.spatialreference,cause it's write only, so I write the code like that
  Dim pBasicmap As IBasicMap
            'Dim ilayer As ILayer
            
            'ilayer = CType(m_pScenecontrol.CustomProperty, ILayer)
            pBasicmap = CType(m_pScenecontrol.Scene, IBasicMap)
            'pBasicmap.DeleteLayer(ilayer)

            pt.SpatialReference = pBasicmap.SpatialReference
            pt.Project(m_pScenecontrol.Scene.SpatialReference)




but the result still don't change.  cause i am a  newcomer ,and people around me can't do this either ,so i have to turn to you.please... with all due respect, could tell me  your e-mail ,i have so many questions ...Really appreciate!
0 Kudos