You are here: > ESRI Forums > arcgis desktop discussion forums > Thread Replies

ArcGIS Desktop Discussion Forums

ArcGIS Desktop - Extension - Spatial Analyst forum

Using 3DAnalyst COM extensions with Visual...   Matthew Tucknott May 15, 2002
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Using 3DAnalyst COM extensions with Visual C++ 
Author Matthew Tucknott 
Date May 15, 2002 
Message Hi,

I am using ESRI ARCObjects with Visual C++. What I want to do is render a raster image in 3D. I think this should be easy but I can't find much help regarding the 3D extensions especially using Visual C++. I have based my code on pretty much how I display a raster image in 2D. Here is the
code, I do not get any errors but neither do I display an image. It is an MFC - SDI based app.

I am sure I need to use other COM objects but I do not know which ones, for a start I think I have to draw the scene differently as it is using OpenGL.

Also is there any samples out there using the 3D extensions in VC++.

Thanks

Matt
 
 
// Relevant state and methods
CStatic	m_CStaticScene;
IScenePtr m_ipScene;
IRasterLayerPtr m_ipRasterLayer;

void CWKDemo3dView::OnInitialUpdate()
{
  std::string SMETHOD("OnInitialUpdate::");
  try 
  {
  CFormView::OnInitialUpdate();
  GetParentFrame()->RecalcLayout();
  ResizeParentToFit();
  m_ipRasterLayer.CreateInstance(CLSID_RasterLayer);
  m_ipRasterLayer->CreateFromFilePath(CComBSTR
                       ("c:/DemoData/guk182bng.img"));
  // Create the scene
  m_ipScene.CreateInstance(CLSID_Scene);
  VARIANT_BOOL bAutoArrange(false);
  m_ipScene->raw_AddLayer(m_ipRasterLayer, bAutoArrange);
  IActiveViewPtr ipActiveView(m_ipScene);
  ipActiveView->raw_Activate((OLE_HANDLE)
                              m_CStaticScene.m_hWnd);

  }

  catch (_com_error &comEx)
  {
    _bstr_t bString = comEx.ErrorMessage();
    std::string Message(SCLASSNAME+SMETHOD+std::string(":")
                        +std::string
                       (bString.operator char *()));
    MessageBox(Message.c_str());
  } 
}

void CWKDemo3dView::OnDraw(CDC* pDC)
{
  // TODO: Add your specialized code here and/or call  
  // the base class
  CWnd* ptr = GetDlgItem( IDC_SCENE );
  ITrackCancelPtr ipCancelTracker;
  ipCancelTracker.CreateInstance(CLSID_CancelTracker);
  IActiveViewPtr ipActiveView;
  ipActiveView = m_ipScene;
  ipActiveView->Draw((OLE_HANDLE)
                      pDC->m_hDC,ipCancelTracker); 
  CFormView::OnDraw(pDC);
}