void CDlgFilterVertexSelection::DoDataExchange(CDataExchange* pDX)
{
  CWorldEditorDoc* pDoc = theApp.GetActiveDocument();
  // if dialog is recieving data
  if( pDX->m_bSaveAndValidate == FALSE)
  {
  }

	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDlgFilterVertexSelection)
	DDX_Text(pDX, IDC_MAX_Y, m_fMaxY);
	DDX_Text(pDX, IDC_MAX_X, m_fMaxX);
	DDX_Text(pDX, IDC_MAX_Z, m_fMaxZ);
	DDX_Text(pDX, IDC_MIN_X, m_fMinX);
	DDX_Text(pDX, IDC_MIN_Y, m_fMinY);
	DDX_Text(pDX, IDC_MIN_Z, m_fMinZ);
	//}}AFX_DATA_MAP

  // if dialog is giving data
  if( pDX->m_bSaveAndValidate != FALSE)
  {
    CDynamicContainer<CBrushVertex> dcVertices;
    {FOREACHINDYNAMICCONTAINER( pDoc->m_selVertexSelection, CBrushVertex, itvtx)
    {
      dcVertices.Add( itvtx);
    }}

    // for each of the dynamic container
    {FOREACHINDYNAMICCONTAINER( dcVertices, CBrushVertex, itvtx)
    {
      BOOL bDeselect=FALSE;
      FLOAT3D vVtx=itvtx->bvx_vAbsolute;
      if(vVtx(1)<m_fMinX || vVtx(1)>m_fMaxX) bDeselect=TRUE;
      if(vVtx(2)<m_fMinY || vVtx(2)>m_fMaxY) bDeselect=TRUE;
      if(vVtx(3)<m_fMinZ || vVtx(3)>m_fMaxZ) bDeselect=TRUE;

      if( bDeselect)
      {
        pDoc->m_selVertexSelection.Deselect( *itvtx);
      }
    }}
Пример #2
0
void CStock_TYPE::FreeUnused(void)
{
  BOOL bAnyRemoved;
  // repeat
  do {
    // create container of objects that should be freed
    CDynamicContainer<TYPE> ctToFree;
    {FOREACHINDYNAMICCONTAINER(st_ctObjects, TYPE, itt) {
      if (!itt->IsUsed()) {
        ctToFree.Add(itt);
      }
    }}
    bAnyRemoved = ctToFree.Count()>0;
    // for each object that should be freed
    {FOREACHINDYNAMICCONTAINER(ctToFree, TYPE, itt) {
      st_ctObjects.Remove(itt);
      st_ntObjects.Remove(itt);
      delete (&*itt);
    }}

  // as long as there is something to remove
  } while (bAnyRemoved);

}
Пример #3
0
/*
 * Converts data from Exploration3D format into arrays used for conversion to O3D
 */
void FillConversionArrays_t(const FLOATmatrix3D &mTransform)
{
#if USE_E3D
  // all polygons must be triangles
  if(_pe3Object->_facecount != 0)
  {
    throw("Error: Not all polygons are triangles!");
  }

  // check if we need flipping (if matrix is flipping, polygons need to be flipped)
  const FLOATmatrix3D &m = mTransform;
  FLOAT fDet = 
    m(1,1)*(m(2,2)*m(3,3)-m(2,3)*m(3,2))+
    m(1,2)*(m(2,3)*m(3,1)-m(2,1)*m(3,3))+
    m(1,3)*(m(2,1)*m(3,2)-m(2,2)*m(3,1));
  FLOAT bFlipped = fDet<0;

  // ------------  Convert object vertices (coordinates)
  INDEX ctVertices = _pe3Object->pointcount;
  avVertices.New(ctVertices);
  // copy vertices
  for( INDEX iVtx=0; iVtx<ctVertices; iVtx++)
  {
    avVertices[iVtx] = ((FLOAT3D &)_pe3Object->points[iVtx])*mTransform;
    avVertices[iVtx](1) = -avVertices[iVtx](1);
    avVertices[iVtx](3) = -avVertices[iVtx](3);
  }

  // ------------ Convert object's mapping vertices (texture vertices)
  INDEX ctTextureVertices = _pe3Object->txtcount;
  avTextureVertices.New(ctTextureVertices);
  // copy texture vertices
  for( INDEX iTVtx=0; iTVtx<ctTextureVertices; iTVtx++)
  {
    avTextureVertices[iTVtx] = (FLOAT2D &)_pe3Object->txtpoints[iTVtx];
  }
  
  // ------------ Organize triangles as list of surfaces
  // allocate triangles
  INDEX ctTriangles = _pe3Object->facecount;
  actTriangles.New(ctTriangles);

  acmMaterials.Lock();
  
  // sort triangles per surfaces
  for( INDEX iTriangle=0; iTriangle<ctTriangles; iTriangle++)
  {
    ConversionTriangle &ctTriangle = actTriangles[iTriangle];
    e3_TFACE *pe3Triangle = _pe3Object->GetFace( iTriangle);
    // copy vertex indices
    if (bFlipped) {
      ctTriangle.ct_iVtx[0] = pe3Triangle->v[2];
      ctTriangle.ct_iVtx[1] = pe3Triangle->v[1];
      ctTriangle.ct_iVtx[2] = pe3Triangle->v[0];
    } else {
      ctTriangle.ct_iVtx[0] = pe3Triangle->v[0];
      ctTriangle.ct_iVtx[1] = pe3Triangle->v[1];
      ctTriangle.ct_iVtx[2] = pe3Triangle->v[2];
    }
    // copy texture vertex indices
    if (bFlipped) {
      ctTriangle.ct_iTVtx[0] = pe3Triangle->t[2];
      ctTriangle.ct_iTVtx[1] = pe3Triangle->t[1];
      ctTriangle.ct_iTVtx[2] = pe3Triangle->t[0];
    } else {
      ctTriangle.ct_iTVtx[0] = pe3Triangle->t[0];
      ctTriangle.ct_iTVtx[1] = pe3Triangle->t[1];
      ctTriangle.ct_iTVtx[2] = pe3Triangle->t[2];
    }

    // obtain material
    e3_MATERIAL *pe3Mat = pe3Triangle->material;
    BOOL bNewMaterial = TRUE;
    // attach triangle into one material
    for( INDEX iMat=0; iMat<acmMaterials.Count(); iMat++)
    {
      // if this material already exist in array of materu
      if( acmMaterials[ iMat].cm_ulTag == (ULONG) pe3Mat)
      {
        // set index of surface
        ctTriangle.ct_iMaterial = iMat;
        // add triangle into surface list of triangles
        INDEX *piNewTriangle = new INDEX(1);
        *piNewTriangle = iTriangle;
        acmMaterials[ iMat].ms_Polygons.Add( piNewTriangle);
        bNewMaterial = FALSE;
        continue;
      }
    }
    // if material hasn't been added yet
    if( bNewMaterial)
    {
      // add new material
      ConversionMaterial *pcmNew = new ConversionMaterial;
      acmMaterials.Unlock();
      acmMaterials.Add( pcmNew);
      acmMaterials.Lock();
      // set polygon's material index 
      INDEX iNewMaterial = acmMaterials.Count()-1;
      ctTriangle.ct_iMaterial = iNewMaterial;
      // add triangle into new surface's list of triangles
      INDEX *piNewTriangle = new INDEX(1);
      *piNewTriangle = iTriangle;
      acmMaterials[ iNewMaterial].ms_Polygons.Add( piNewTriangle);
      
      // remember recognition tag (ptr)
      pcmNew->cm_ulTag = (ULONG) pe3Mat;

      // ---------- Set material's name
      // if not default material
      if( pe3Mat != NULL && pe3Mat->name != NULL)
      {
        acmMaterials[iNewMaterial].cm_strName = CTString(pe3Mat->name);
        // get color
        COLOR colColor = CLR_CLRF( pe3Mat->GetDiffuse().rgb());
        acmMaterials[iNewMaterial].cm_colColor = colColor;
      }
      else
      {
        acmMaterials[iNewMaterial].cm_strName = "Default";
        acmMaterials[iNewMaterial].cm_colColor = C_GRAY;
      }
    }
  }
  acmMaterials.Unlock();
#endif
}