Ejemplo n.º 1
0
void CModelerDoc::OnFileAddTexture() 
{
  CModelerView *pModelerView = CModelerView::GetActiveView();
  if( pModelerView == NULL)
    return;

  // call file requester for adding textures
  CDynamicArray<CTFileName> afnTextures;
  CTFileName fnDocName = CTString(GetPathName());
  theApp.WriteProfileString( "Scape", "Add texture directory", fnDocName.FileDir());
  _EngineGUI.FileRequester( "Choose textures to add", FILTER_TEX FILTER_END,
    "Add texture directory", "Textures\\", fnDocName.FileName()+".tex", &afnTextures);
  MEX mexWidth, mexHeight;
  m_emEditModel.edm_md.GetTextureDimensions( mexWidth, mexHeight);
  // add selected textures
  FOREACHINDYNAMICARRAY( afnTextures, CTFileName, itTexture)
  {
    CTextureDataInfo *pNewTDI;
    // add texture
    CTFileName fnTexName = itTexture.Current();
    try
    {
      pNewTDI =m_emEditModel.AddTexture_t( fnTexName, mexWidth, mexHeight);
    }
    catch( char *err_str)
    {
      pNewTDI = NULL;
      AfxMessageBox( err_str);
    }
    if( pNewTDI != NULL)
    {
      SetModifiedFlag();
      pModelerView->m_ptdiTextureDataInfo = pNewTDI;
      // switch to texture mode
      pModelerView->OnRendUseTexture();
      UpdateAllViews( NULL);
    }
  }
Ejemplo n.º 2
0
void CMainFrame::OnFileCreateTexture() 
{
  CModelerView *pView = (CModelerView *) CModelerView::GetActiveView();
  CModelerDoc *pDoc = NULL;
  if( pView != NULL)
  {
    pDoc = pView->GetDocument();
    // setup create texture directory
    theApp.WriteProfileString("Scape", KEY_NAME_CREATE_TEXTURE_DIR, 
      _fnmApplicationPath+pDoc->GetModelDirectory());
  }
  // call create texture dialog
  CTFileName fnCreated = _EngineGUI.CreateTexture();
  if( (fnCreated != "") && pDoc != NULL)
  {
    CTextureDataInfo *pNewTDI;
    try
    {
      pNewTDI = pDoc->m_emEditModel.AddTexture_t( fnCreated, 
                pDoc->m_emEditModel.GetWidth(),
                pDoc->m_emEditModel.GetHeight() );
    }
    catch( char *err_str)
    {
      AfxMessageBox( err_str);
      pNewTDI = NULL;
    }
    if( pNewTDI != NULL)
    {
      pDoc->SetModifiedFlag();
      pView->m_ptdiTextureDataInfo = pNewTDI;
      // switch to texture mode
      pView->OnRendUseTexture();
    }
  }
}