// check if all of the corners of entity's bounding box are influenced by current select-on-render selection void SelectEntityOnRender(CProjection3D &prProjection, CEntity &en) { FLOATaabbox3D bbox; FLOATmatrix3D mOne = FLOATmatrix3D(0.0f); mOne.Diagonal(1.0f); FLOATmatrix3D *pmR; FLOAT3D vOffset; // if this entity is model if (en.en_RenderType==CEntity::RT_MODEL || en.en_RenderType==CEntity::RT_EDITORMODEL) { // get bbox of current frame CModelObject *pmo = en.GetModelObject(); pmo->GetCurrentFrameBBox( bbox); pmR = &en.en_mRotation; vOffset = en.GetPlacement().pl_PositionVector; } // if it is ska model else if(en.en_RenderType==CEntity::RT_SKAMODEL || en.en_RenderType==CEntity::RT_SKAEDITORMODEL) { en.GetModelInstance()->GetCurrentColisionBox( bbox); pmR = &en.en_mRotation; vOffset = en.GetPlacement().pl_PositionVector; } // if it is brush else { // get bbox of brush's first mip CBrush3D *pbr = en.GetBrush(); CBrushMip *pbrmip = pbr->GetFirstMip(); bbox = pbrmip->bm_boxBoundingBox; pmR = &mOne; vOffset = FLOAT3D( 0.0f, 0.0f, 0.0f); } if( IsBoundingBoxInLasso( prProjection, bbox, pmR, vOffset)) { if( _bSelectAlternative) { // deselect if (en.IsSelected(ENF_SELECTED)) { _pselenSelectOnRender->Deselect(en); } } else { // select if (!en.IsSelected(ENF_SELECTED)) { _pselenSelectOnRender->Select(en); } } } }
static FLOATaabbox3D AddAllVerticesToBBox(CModelInstance &mi) { FLOATmatrix3D mat; FLOAT3D vPos = FLOAT3D(0,0,0); mat.Diagonal(1); CStaticStackArray<FLOAT3D> avVertices; mi.GetModelVertices(avVertices,mat,vPos,0,0); INDEX ctvtx = avVertices.Count(); // if at least one vertex exists FLOATaabbox3D bbox; if(ctvtx>0) { bbox = FLOATaabbox3D(avVertices[0]); // for each vertex after first one for(INDEX ivx=1;ivx<ctvtx;ivx++) { // add this vertex position to all frames bbox bbox |= FLOATaabbox3D(avVertices[ivx]); } } return bbox; }
void CObject3D::LoadAny3DFormat_t( const CTFileName &fnmFileName, const FLOATmatrix3D &mTransform, enum LoadType ltLoadType/*= LT_NORMAL*/) { #if USE_E3D BOOL bWasOn = _bBatchLoading; try { if (!_bBatchLoading) { BatchLoading_t(TRUE); } // call file load with file's full path name CTString strFile = _fnmApplicationPath+fnmFileName; char acFile[MAX_PATH]; wsprintf(acFile,"%s",strFile); e3_LoadFile(_hwnd, acFile); _pe3Scene=e3_GetScene(_hwnd); // if scene is successefuly loaded if(_pe3Scene != NULL) { _pe3Object = _pe3Scene->GetObject3d( 0); // use different methods to convert into Object3D switch( ltLoadType) { case LT_NORMAL: FillConversionArrays_t(mTransform); ConvertArraysToO3D(); break; case LT_OPENED: FillConversionArrays_t(mTransform); RemapVertices(TRUE); ConvertArraysToO3D(); break; case LT_UNWRAPPED: FLOATmatrix3D mOne; mOne.Diagonal(1.0f); FillConversionArrays_t(mOne); if( avTextureVertices.Count() == 0) { ThrowF_t("Unable to import mapping from 3D object because it doesn't contain mapping coordinates."); } RemapVertices(FALSE); ConvertArraysToO3D(); break; } ClearConversionArrays(); } else { ThrowF_t("Unable to load 3D object: %s", (const char *)fnmFileName); } if (!bWasOn) { BatchLoading_t(FALSE); } } catch (char *) { if (!bWasOn) { BatchLoading_t(FALSE); } throw; } #endif }