void CPedModelInfo::CreateHitColModelSkinned(RpClump* clump) { RpHAnimHierarchy* hier = GetAnimHierarchyFromSkinClump(clump); CColModel* hitColModel = new CColModel; RwMatrixTag* frameInverseMat = CGame::GetWorkingMatrix1(); RwMatrixTag* transformMatrix = CGame::GetWorkingMatrix2(); hitColModel->AllocateData(12, 0, 0, 0, 0, 0); RwMatrixInvert(frameInverseMat, &RpClumpGetFrame(clump)->modelling); for (size_t i = 0; i < ELEMS_COUNT(m_pColNodeInfos); i++) { CColSphere colSphere; colSphere.Set(m_pColNodeInfos[i].sphere.GetRadius(), m_pColNodeInfos[i].sphere.GetCenter()); CCollisionData* colData = hitColModel->GetColData(); *transformMatrix = *frameInverseMat; RwInt32 matIndex = RpHAnimIDGetIndex(hier, m_pColNodeInfos[i].animId) << 6; RwMatrix* mat = (RwMatrix*)(RpHAnimHierarchyGetMatrixArray(hier) + matIndex); RwMatrixTransform((RwMatrix *)transformMatrix, mat, rwCOMBINEPRECONCAT); RwV3dTransformPoints(&colSphere.center, &colSphere.center, 1, (RwMatrix *)transformMatrix); colSphere.SetSurfaceTypeA(EColSurface::PED); colSphere.SetSurfaceTypeB(m_pColNodeInfos[i].surfaceTypeB); colData->SetSphere(i, colSphere); } CBoundingBox boundingBox; CVector maxbb(0.5f, 0.5f, 1.2f); CVector minbb(-0.5f,-0.5f,-1.2f); CBox box; box.Set(minbb, maxbb); boundingBox.SetBoundingSphere(CSphere(0, 0, 0, 1.5f)); hitColModel->SetBoundingBox(boundingBox); hitColModel->SetColNum(0); m_hitColModel = hitColModel; }
void CPed::renderLimb(int node) { RpAtomic *atomic; CPedModelInfo *pedinfo = (CPedModelInfo*)CModelInfo::ms_modelInfoPtrs[this->nModelIndex]; switch(node){ case PED_HEAD: atomic = pedinfo->head; break; case PED_HANDL: atomic = pedinfo->lhand; break; case PED_HANDR: atomic = pedinfo->rhand; break; default: return; } if(atomic == NULL) return; RpHAnimHierarchy *hier = GetAnimHierarchyFromSkinClump(this->clump); int idx = RpHAnimIDGetIndex(hier, this->frames[node]->nodeID); RwMatrix *mat = &RpHAnimHierarchyGetMatrixArray(hier)[idx]; RwFrame *frame = RpAtomicGetFrame(atomic); frame->modelling = *mat; RwFrameUpdateObjects(frame); int alpha = CVisibilityPlugins__GetClumpAlpha(clump); RpGeometryForAllMaterials(RpAtomicGetGeometry(atomic), SetAlphaCB, &alpha); atomic->renderCallBack(atomic); }
void FxSystem_c::AttachToBone(CEntity* entity, int boneId) { RpHAnimHierarchy* animHier = GetAnimHierarchyFromSkinClump((RpClump*)entity->GetRwObject()); RwInt32 nodeIndex = RpHAnimIDGetIndex(animHier, boneId); RwMatrix* matrixArray = RpHAnimHierarchyGetMatrixArray(animHier); m_parentMatrix = &matrixArray[nodeIndex]; }
void __fastcall cped__render__hook(CPed *ped) { ped->CEntity::Render(); if(IsClumpSkinned(ped->clump)){ ped->renderLimb(PED_HEAD); ped->renderLimb(PED_HANDL); ped->renderLimb(PED_HANDR); int pedid = CPools__GetPedRef(ped) >> 8; RpAtomic *atomic = weaponAtomics[pedid]; if(atomic){ RpHAnimHierarchy *hier = GetAnimHierarchyFromSkinClump(ped->clump); int idx = RpHAnimIDGetIndex(hier, ped->frames[PED_HANDR]->nodeID); RwMatrix *mat = &RpHAnimHierarchyGetMatrixArray(hier)[idx]; RwFrame *frame = RpAtomicGetFrame(atomic); memcpy(RwFrameGetMatrix(frame), mat, 64); RwFrameUpdateObjects(frame); atomic->renderCallBack(atomic); } }
CColModel* CPedModelInfo::AnimatePedColModelSkinned(RpClump* clump) { v2 = this; v3 = this->HitColModel; v21 = this; if (!m_hitColModel) { CreateHitColModelSkinned(clump); return m_hitColModel; } v20 = v3->pColData; v5 = GetAnimHierarchyFromSkinClump(c); v6 = CGame::m_pWorkingMatrix1; v7 = CGame::m_pWorkingMatrix2; v8 = &c->object.parent->modelling; v19 = v5; LODWORD(b.x) = 0; LODWORD(b.y) = 0; LODWORD(b.z) = 0; v18 = CGame::m_pWorkingMatrix1; unk_7F2070(CGame::m_pWorkingMatrix1, v8); ca = 0; v9 = (char *)&CPedModelInfo::m_pColNodeInfos[0].sphere.vecPosition.fY; do { LODWORD(v10) = *((_DWORD *)v9 - 1); LODWORD(v11) = *((_DWORD *)v9 + 1); LODWORD(center.y) = *(_DWORD *)v9; center.x = v10; center.z = v11; memcpy(v7, v6, 0x40u); v12 = RpHAnimIDGetIndex(v19, *((_DWORD *)v9 - 3)) << 6; RpHAnimHierarchyGetMatrixArray(v19); RwMatrixTransform((RwMatrix *)v7, (RwMatrix *)(v13 + v12), 1); v7EDD90(¢er, ¢er, 1, (RwMatrix *)v7); v6 = v18; v14 = (int)((char *)v20->m_pSpheres + ca); *(_DWORD *)v14 = (_DWORD)center.x; *(_DWORD *)(v14 + 4) = LODWORD(center.y); v9 += 28; *(_DWORD *)(v14 + 8) = LODWORD(center.z); ca += 20; } while ( (signed int)v9 < (signed int)&componentListCar ); center.y = b.y; LODWORD(center.x) = (_DWORD)b.x; center.z = b.z; memcpy(v7, v18, 0x40u); v15 = RpHAnimIDGetIndex(v19, 3); RpHAnimHierarchyGetMatrixArray(v19); RwMatrixTransform((RwMatrix *)v7, (RwMatrix *)((v15 << 6) + v16), 1); v7EDD90(¢er, ¢er, 1, (RwMatrix *)v7); CSphere::Set((RwSphere *)&v21->HitColModel->boundingBox.vecBoundOffset, 1.5, ¢er); b.x = center.x + 1.2; b.y = center.y + 1.2; b.z = center.z + 1.2; a.x = center.x - 1.2; a.y = center.y - 1.2; a.z = center.z - 1.2; v17 = (CBox *)v21->HitColModel; CBox::Set(v17, &a, &b); return m_hitColModel; }
void CEntity::UpdateRpHAnim(void) { RpHAnimHierarchy *hier = GetAnimHierarchyFromSkinClump(this->clump); RpHAnimHierarchyUpdateMatrices(hier); }