Ogre 獲取實體頂點和索引

2021-06-05 10:32:54 字數 1707 閱讀 4085

bool added_shared = false;

size_t current_offset = 0;

size_t shared_offset = 0;

size_t next_offset = 0;

size_t index_offset = 0;

size_t index_count = 0;

size_t vertex_count = 0;

meshptr ogreheadmesh = polacub1->getmesh();

for(unsigned short i = 0; i< ogreheadmesh->getnumsubmeshes(); i++)

}else

index_count += submesh->indexdata->indexcount;

}ogre::vector3* vertices = new vector3[vertex_count];

long* indices = new long[index_count];

for(unsigned short i = 0; i < ogreheadmesh->getnumsubmeshes(); i++)

const vertexelement* poselem = vertex_data->vertexdeclaration->findelementbysemantic(ogre::ves_position);

ogre::hardwarevertexbuffersharedptr vbuf = vertex_data->vertexbufferbinding->getbuffer(poselem->getsource());

unsigned char* vertex = static_cast(vbuf->lock(ogre::hardwarebuffer::hbl_read_only));

float* preal;

for(size_t j = 0; j < vertex_data->vertexcount; j++,vertex += vbuf->getvertexsize())

vbuf->unlock();

next_offset += vertex_data->vertexcount;

}indexdata* index_data = submesh->indexdata;

size_t numtris = index_data->indexcount / 3;

ogre::hardwareindexbuffersharedptr ibuf = index_data->indexbuffer;

bool use32bitindexs = (ibuf->gettype() == ogre::hardwareindexbuffer::it_32bit);

unsigned long* plong = static_cast(ibuf->lock(ogre::hardwarebuffer::hbl_read_only));

unsigned short* pshort = reinterpret_cast(plong);

size_t offset = (submesh->usesharedvertices) ? shared_offset : current_offset;

if(use32bitindexs)

}else

}ibuf->unlock();

current_offset = next_offset;

頂點緩衝區VBO和索引緩衝區IBO的結合使用

virtual void oninit 將記憶體中的頂點資料傳送進視訊記憶體 glbufferdata gl array buffer,sizeof pos pos,gl static draw 切換狀態 glbindbuffer gl array buffer,0 建立索引緩衝區 glgenbuf...

實體完整性檢查和違約處(B 樹索引介紹)

1.檢查主碼值是否唯一,如果不唯一則拒絕插入或修改。2.檢查主碼的各個屬性是否為空,只要有乙個為空就拒絕插入或修改。檢查記錄中主碼值是否唯一的一種方法是進行全表掃瞄,全表掃瞄是十分耗時的,為了避免對基本表進行全表掃瞄,關聯式資料庫管理系統一般都在主碼上自動建立乙個索引。例如b 樹索引,通過索引查詢基...

C 獲取實體類屬性名和值 遍歷類物件

遍歷獲得乙個實體類的所有屬性名,以及該類的所有屬性的值 先定義乙個類 public class user public string gender public string age 例項化類,並給實列化對像的屬性賦值 user u new user u.name ahbool u.gender 男...