void ControlPanel::initBodypartChoices() { CStudioHdr *hdr = models->GetActiveStudioModel()->GetStudioHdr(); if (hdr) { int i; mstudiobodyparts_t *pbodyparts = hdr->pBodypart(0); cBodypart->removeAll(); if (hdr->numbodyparts() > 0) { for (i = 0; i < hdr->numbodyparts(); i++) cBodypart->add (pbodyparts[i].pszName()); cBodypart->select (0); cSubmodel->removeAll(); for (i = 0; i < pbodyparts[0].nummodels; i++) { char str[64]; sprintf (str, "Submodel %d", i + 1); cSubmodel->add (str); } cSubmodel->select (0); } } }
bool StudioModel::PostLoadModel( const char *modelname ) { MDLCACHE_CRITICAL_SECTION_( g_pMDLCache ); CStudioHdr *pStudioHdr = GetStudioHdr(); if (pStudioHdr == NULL) return false; SetSequence (0); SetController (0, 0.0f); SetController (1, 0.0f); SetController (2, 0.0f); SetController (3, 0.0f); SetBlendTime( DEFAULT_BLEND_TIME ); // SetHeadTurn( 1.0f ); // FIXME:!!! int n; for (n = 0; n < pStudioHdr->numbodyparts(); n++) { SetBodygroup (n, 0); } SetSkin (0); /* Vector mins, maxs; ExtractBbox (mins, maxs); if (mins[2] < 5.0f) m_origin[2] = -mins[2]; */ return true; }
void StudioModel::scaleMeshes (float scale) { CStudioHdr *pStudioHdr = GetStudioHdr(); if (!pStudioHdr) return; int i, j, k; // manadatory to access correct verts SetCurrentModel(); // scale verts int tmp = m_bodynum; for (i = 0; i < pStudioHdr->numbodyparts(); i++) { mstudiobodyparts_t *pbodypart = pStudioHdr->pBodypart( i ); for (j = 0; j < pbodypart->nummodels; j++) { SetBodygroup (i, j); SetupModel (i); const mstudio_modelvertexdata_t *vertData = m_pmodel->GetVertexData(); for (k = 0; k < m_pmodel->numvertices; k++) { *vertData->Position(k) *= scale; } } } m_bodynum = tmp; // scale complex hitboxes int hitboxset = g_MDLViewer->GetCurrentHitboxSet(); mstudiobbox_t *pbboxes = pStudioHdr->pHitbox( 0, hitboxset ); for (i = 0; i < pStudioHdr->iHitboxCount( hitboxset ); i++) { VectorScale (pbboxes[i].bbmin, scale, pbboxes[i].bbmin); VectorScale (pbboxes[i].bbmax, scale, pbboxes[i].bbmax); } // scale bounding boxes for (i = 0; i < pStudioHdr->GetNumSeq(); i++) { mstudioseqdesc_t &seqdesc = pStudioHdr->pSeqdesc( i ); Vector tmp; tmp = seqdesc.bbmin; VectorScale( tmp, scale, tmp ); seqdesc.bbmin = tmp; tmp = seqdesc.bbmax; VectorScale( tmp, scale, tmp ); seqdesc.bbmax = tmp; } // maybe scale exeposition, pivots, attachments }
//------------------------------------------------------------------------------ // Returns true if the model has at least one body part with model data, false if not. //------------------------------------------------------------------------------ bool StudioModel::HasModel() { CStudioHdr *pStudioHdr = GetStudioHdr(); if ( !pStudioHdr ) return false; for ( int i = 0; i < pStudioHdr->numbodyparts(); i++ ) { if ( pStudioHdr->pBodypart(i)->nummodels ) { return true; } } return false; }
int StudioModel::SetBodygroup( int iGroup, int iValue ) { CStudioHdr *pStudioHdr = GetStudioHdr(); if (!pStudioHdr) return 0; if (iGroup > pStudioHdr->numbodyparts()) return -1; mstudiobodyparts_t *pbodypart = pStudioHdr->pBodypart( iGroup ); int iCurrent = (m_bodynum / pbodypart->base) % pbodypart->nummodels; if (iValue >= pbodypart->nummodels) return iCurrent; m_bodynum = (m_bodynum - (iCurrent * pbodypart->base) + (iValue * pbodypart->base)); return iValue; }
void ControlPanel::setModelInfo() { static char str[2048]; CStudioHdr *hdr = models->GetActiveStudioModel()->GetStudioHdr(); if (!hdr) return; int hbcount = 0; for ( int s = 0; s < hdr->numhitboxsets(); s++ ) { hbcount += hdr->iHitboxCount( s ); } sprintf (str, "Bones: %d\n" "Bone Controllers: %d\n" "Hit Boxes: %d in %d sets\n" "Sequences: %d\n", hdr->numbones(), hdr->numbonecontrollers(), hbcount, hdr->numhitboxsets(), hdr->GetNumSeq() ); lModelInfo1->setLabel (str); sprintf (str, "Textures: %d\n" "Skin Families: %d\n" "Bodyparts: %d\n" "Attachments: %d\n", hdr->numtextures(), hdr->numskinfamilies(), hdr->numbodyparts(), hdr->GetNumAttachments()); lModelInfo2->setLabel (str); }
void ControlPanel::setBodypart (int index) { CStudioHdr *hdr = models->GetActiveStudioModel()->GetStudioHdr(); if (hdr) { //cBodypart->setEn cBodypart->select (index); if (index < hdr->numbodyparts()) { mstudiobodyparts_t *pbodyparts = hdr->pBodypart(0); cSubmodel->removeAll(); for (int i = 0; i < pbodyparts[index].nummodels; i++) { char str[64]; sprintf (str, "Submodel %d", i + 1); cSubmodel->add (str); } cSubmodel->select (0); //models->GetActiveStudioModel()->SetBodygroup (index, 0); } } }