// Create model instance and parse smc file in it CModelInstance *ParseSmcFile_t(const CTString &fnSmcFile) { _yy_mi = NULL; // Create new model instance for parser _yy_mi = CreateModelInstance("Temp"); // Parse given smc file ParseSmcFile_t(*_yy_mi,fnSmcFile); return _yy_mi; }
// copy from another object of same class void CModelInstance::Copy(CModelInstance &miOther) { // clear this instance - otherwise it won't work Clear(); mi_aqAnims.aq_Lists = miOther.mi_aqAnims.aq_Lists; mi_iCurentBBox = miOther.mi_iCurentBBox; mi_colModelColor = miOther.mi_colModelColor; mi_iParentBoneID = miOther.mi_iParentBoneID; mi_qvOffset = miOther.mi_qvOffset; mi_strName = miOther.mi_strName; mi_iModelID = miOther.mi_iModelID; mi_cbAABox = miOther.mi_cbAABox; mi_fnSourceFile = miOther.mi_fnSourceFile; mi_vStretch = miOther.mi_vStretch; // copt mesh instance CopyMeshInstance(miOther); // if skeleton exists if(miOther.mi_psklSkeleton!=NULL) { // copy skeleton AddSkeleton_t(miOther.mi_psklSkeleton->GetName()); } // copy animsets INDEX ctas = miOther.mi_aAnimSet.Count(); // for each animset for(INDEX ias=0;ias<ctas;ias++) { // add animset to this model instance CAnimSet &asOther = miOther.mi_aAnimSet[ias]; AddAnimSet_t(asOther.GetName()); } // copy children INDEX ctch = miOther.mi_cmiChildren.Count(); // for each child in other model instance for(INDEX ich=0;ich<ctch;ich++) { CModelInstance &chmiOther = miOther.mi_cmiChildren[ich]; CModelInstance *pchmi = CreateModelInstance("Temp"); pchmi->Copy(chmiOther); AddChild(pchmi); } }
//----------------------------------------------------------------------------- // Purpose: Draws the object // Input : flags - //----------------------------------------------------------------------------- bool C_PhysicsProp::OnInternalDrawModel( ClientModelRenderInfo_t *pInfo ) { CreateModelInstance(); if ( r_PhysPropStaticLighting.GetBool() && m_bAwakeLastTime != m_bAwake ) { if ( m_bAwakeLastTime && !m_bAwake ) { // transition to sleep, bake lighting now, once if ( !modelrender->RecomputeStaticLighting( GetModelInstance() ) ) { // not valid for drawing return false; } if ( r_visualizeproplightcaching.GetBool() ) { float color[] = { 0.0f, 1.0f, 0.0f, 1.0f }; render->SetColorModulation( color ); } } else if ( r_visualizeproplightcaching.GetBool() ) { float color[] = { 1.0f, 0.0f, 0.0f, 1.0f }; render->SetColorModulation( color ); } } if ( !m_bAwake && r_PhysPropStaticLighting.GetBool() ) { // going to sleep, have static lighting pInfo->flags |= STUDIO_STATIC_LIGHTING; } // track state m_bAwakeLastTime = m_bAwake; return true; }
/* * Copy entity from another entity of same class. * NOTES: * - Doesn't copy placement, it must be done on creation. * - Entity must be initialized afterwards. */ void CEntity::Copy(CEntity &enOther, ULONG ulFlags) { BOOL bRemapPointers = ulFlags & COPY_REMAP; // copy base class data en_RenderType = enOther.en_RenderType; en_ulPhysicsFlags = enOther.en_ulPhysicsFlags; en_ulCollisionFlags = enOther.en_ulCollisionFlags; en_ulFlags = enOther.en_ulFlags & ~(ENF_SELECTED|ENF_FOUNDINGRIDSEARCH|ENF_VALIDSHADINGINFO|ENF_INRENDERING); en_ulSpawnFlags = enOther.en_ulSpawnFlags; // if this is a brush if ( enOther.en_RenderType == RT_BRUSH || en_RenderType == RT_FIELDBRUSH) { // there must be no existing brush ASSERT(en_pbrBrush == NULL); // create a new empty brush in the brush archive of current world en_pbrBrush = en_pwoWorld->wo_baBrushes.ba_abrBrushes.New(); en_pbrBrush->br_penEntity = this; // copy the brush if (_bMirrorAndStretch) { en_pbrBrush->Copy(*enOther.en_pbrBrush, _fStretch, _wmtMirror!=WMT_NONE); } else { en_pbrBrush->Copy(*enOther.en_pbrBrush, 1.0f, FALSE); } // if this is a terrain } else if( enOther.en_RenderType == RT_TERRAIN) { ASSERT(en_ptrTerrain == NULL); // create a new empty terrain in the brush archive of current world en_ptrTerrain = en_pwoWorld->wo_taTerrains.ta_atrTerrains.New(); en_ptrTerrain->tr_penEntity = this; // Copy terrain TR_CopyTerrain(en_ptrTerrain,enOther.en_ptrTerrain); // Update terrain shadowmap Matrix12 mTerrain; TR_GetMatrixFromEntity(mTerrain,en_ptrTerrain); TR_UpdateShadowMap(en_ptrTerrain,mTerrain,FLOATaabbox3D()); // if this is a model } if ( enOther.en_RenderType == RT_MODEL || en_RenderType == RT_EDITORMODEL) { // if will not initialize if (!(ulFlags©_REINIT)) { ASSERT(en_pmoModelObject==NULL); ASSERT(en_psiShadingInfo==NULL); if(en_pmoModelObject!=NULL) { delete en_pmoModelObject; } if(en_psiShadingInfo!=NULL) { delete en_psiShadingInfo; } // create a new model object en_pmoModelObject = new CModelObject; en_psiShadingInfo = new CShadingInfo; en_ulFlags &= ~ENF_VALIDSHADINGINFO; // copy it en_pmoModelObject->Copy(*enOther.en_pmoModelObject); } // if this is ska model } else if ( enOther.en_RenderType == RT_SKAMODEL || en_RenderType == RT_SKAEDITORMODEL) { ASSERT(en_psiShadingInfo==NULL); if(en_psiShadingInfo!=NULL) { delete en_psiShadingInfo; } en_psiShadingInfo = new CShadingInfo; en_ulFlags &= ~ENF_VALIDSHADINGINFO; ASSERT(en_pmiModelInstance==NULL); if(en_pmiModelInstance!=NULL) { DeleteModelInstance(en_pmiModelInstance); } en_pmiModelInstance = CreateModelInstance(""); // copy it GetModelInstance()->Copy(*enOther.GetModelInstance()); } // copy the parent pointer if (bRemapPointers) { en_penParent = FindRemappedEntityPointer(enOther.en_penParent); } else { en_penParent = enOther.en_penParent; } // if the entity has a parent if (en_penParent!=NULL) { // create relative offset en_plRelativeToParent = en_plPlacement; en_plRelativeToParent.AbsoluteToRelativeSmooth(en_penParent->en_plPlacement); // link to parent en_penParent->en_lhChildren.AddTail(en_lnInParent); } // copy the derived class properties CopyEntityProperties(enOther, ulFlags); }