Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I am drawing a dynamic moving vehicle like this:

m_dynamicSymbolProperties.set_DynamicGlyph(esriDynamicSymbolType.esriDSymbolMarker, this.bluePoliceCarGlyph);
m_dynamicSymbolProperties.SetScale(esriDynamicSymbolType.esriDSymbolMarker, .3f, .3f);
currentUnitPosition = getNextPosition();
dynamicDisplay.DrawMarker(currentUnitPosition);

Does anyone know an easy way to do a hit test on my vehicle? I am having trouble with this code example, http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#/How_to_identify_objects_in_dynamic_display/0001000004s2000000/


One of the issues I have with the example is that ESRI states:

ArcGIS versions 9.2 and later have the following three display systems that use OpenGL as their underlying drawing pipe—ArcGlobe/GlobeControl, ArcScene/SceneControl, and MapControl's dynamic display.

So I am trying to get a hit test for a dynamic display object, but according to the tutorial, part 1 (link above), I have to use the OpenGL display system to give my dynamic display object a watermark in order for the hit test to work. This makes no sense at all.

uint ID = Convert.ToUInt32(r[0]);
OpenGL.GL.glLoadName(ID);

Another issue I have is when this code is called

IArray dynamicHitArray = m_dynamicDisplay.Locate(x, y,
    esriDynamicSelectionMode.esriDSMLayers, this as IDynamicLayer);

Another event is fired off to DrawDynamicLayer and I will get a stackoverflow unless I do this

if(!someBool)
{
    someBool = true; 
    IArray dynamicHitArray = m_dynamicDisplay.Locate(x, y,
        esriDynamicSelectionMode.esriDSMLayers, this as IDynamicLayer);

  someBool = false; 
}
share|improve this question

1 Answer 1

up vote 0 down vote accepted

I grabbed the OpenGL files from this sample: http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#/Sample_Dynamic_display_compass/0001000004nq000000/

Then in my DynamicLayer (CustomDynamicLayer) I do this:

public override void DrawDynamicLayer(esriDynamicDrawPhase DynamicDrawPhase, IDisplay iDisplay, IDynamicDisplay iDynamicDisplay) 
{

OpenGL.GL.glLoadName(id); //id is arbitrary
m_dynamicSymbolProperties.set_DynamicGlyph(esriDynamicSymbolType.esriDSymbolMarker, unitIcon);
m_dynamicSymbolProperties.SetScale(esriDynamicSymbolType.esriDSymbolMarker, .3f, .3f);
dynamicDisplay2.DrawMarker(position);
}

Then in my main app I have an event handler for AfterDynamicDraw

public void OnAfterDynamicDraw(esriDynamicMapDrawPhase dynamicMapDrawPhase, IDisplay Display, IDynamicDisplay dynamicDisplay) 
{

  IDynamicDisplay2 dynamicDisplay2 = dynamicDisplay as IDynamicDisplay2; 

  //test some x,y that i know i hit
  IArray thisArray = dynamicDisplay2.Locate(674, 249,   esriDynamicSelectionMode.esriDSMLayers, this.customDynamicLayer as IDynamicLayer);
}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.