void KX_FontObject::AddMeshUser() { m_meshUser = new RAS_TextUser(m_pClient_info); // set the part of the mesh slot that never change float *fl = GetOpenGLMatrixPtr()->getPointer(); m_meshUser->SetMatrix(fl); RAS_BucketManager *bucketManager = GetScene()->GetBucketManager(); bool created = false; RAS_MaterialBucket *bucket = bucketManager->FindBucket(GetTextMaterial(), created); // If the material bucket is just created then we add a new mesh slot. if (created) { RAS_TexVertFormat format; format.uvSize = 1; format.colorSize = 1; bucket->NewMesh(NULL, NULL, format); } /* We copy the original mesh slot which is at the begin of the list, if it's not the case it * doesn't matter as the mesh slot are all similar exepted their mesh user pointer which is * set to NULL in copy. By copying instead of adding a mesh slot we reuse the same display * array bucket. */ RAS_MeshSlot *ms = bucket->CopyMesh(*bucket->msBegin()); ms->SetMeshUser(m_meshUser); ms->SetDeformer(NULL); m_meshUser->AddMeshSlot(ms); }
void RAS_MeshObject::AddMeshUser(void *clientobj, SG_QList *head, RAS_Deformer* deformer) { list<RAS_MeshMaterial>::iterator it; list<RAS_MeshMaterial>::iterator mit; for (it = m_materials.begin();it!=m_materials.end();++it) { /* always copy from the base slot, which is never removed * since new objects can be created with the same mesh data */ if (deformer && !deformer->UseVertexArray()) { // HACK! // this deformer doesn't use vertex array => derive mesh // we must keep only the mesh slots that have unique material id // this is to match the derived mesh drawing function // Need a better solution in the future: scan the derive mesh and create vertex array RAS_IPolyMaterial* curmat = it->m_bucket->GetPolyMaterial(); if (curmat->GetFlag() & RAS_BLENDERGLSL) { for (mit = m_materials.begin(); mit != it; ++mit) { RAS_IPolyMaterial* mat = mit->m_bucket->GetPolyMaterial(); if ((mat->GetFlag() & RAS_BLENDERGLSL) && mat->GetMaterialIndex() == curmat->GetMaterialIndex()) // no need to convert current mesh slot break; } if (mit != it) continue; } } RAS_MeshSlot *ms = it->m_bucket->CopyMesh(it->m_baseslot); ms->m_clientObj = clientobj; ms->SetDeformer(deformer); it->m_slots.insert(clientobj, ms); head->QAddBack(ms); } }