void MeshLoader_v0::ReadAnimStream(SubMesh * sm, DataStreamPtr & stream) { VertexDeclarationPtr decl = sm->GetVertexStream()->GetDeclaration(); VertexBufferPtr buffer; int stride = 0; chunk ck; while (ReadChunk(ck, stream) && (ck.id == MC_STREAM_DECLARATION || ck.id == MC_STREAM_VERTEX_DATA)) { switch (ck.id) { case MC_STREAM_DECLARATION: ReadDeclaration(_ANIM_STREAM, decl, stream); break; case MC_STREAM_VERTEX_DATA: ReadVertexStream(buffer, stride, sm->GetVertexStream()->GetCount(), stream); break; } } sm->GetVertexStream()->Bind(_ANIM_STREAM, buffer, stride); //skip if (!stream->Eof()) stream->Skip(-MC_CHUNK_SIZE); }
void MeshLoader_v0::ReadSubMesh(SubMesh * sm, DataStreamPtr & stream) { int iVertexCount; int iIndexCount; int iPrimitiveCount; int iPrimitiveType; String sMaterial; stream->Read(&iVertexCount, sizeof(int)); stream->Read(&iIndexCount, sizeof(int)); stream->Read(&iPrimitiveCount, sizeof(int)); stream->Read(&iPrimitiveType, sizeof(int)); sm->GetVertexStream()->SetCount(iVertexCount); sm->GetIndexStream()->SetCount(iIndexCount); sm->SetPrimitiveCount(iPrimitiveCount); sm->SetPrimitiveType((PRIMITIVE_TYPE)iPrimitiveType); stream->ReadString(sMaterial); //sm->SetMaterialName(sMaterial.c_str()); VertexDeclarationPtr decl = VideoBufferManager::Instance()->CreateVertexDeclaration(); sm->GetVertexStream()->SetDeclaration(decl); //read sub chunk chunk ck; while (ReadChunk(ck, stream) && (ck.id == MC_SUBMESH_TRANSFROM_STREAM || ck.id == MC_SUBMESH_LIGHT_STREAM || ck.id == MC_SUBMESH_TEXCOORD_STREAM || ck.id == MC_SUBMESH_ANIMATION_STREAM || ck.id == MC_SUBMESH_INDEX_STREAM)) { switch (ck.id) { case MC_SUBMESH_TRANSFROM_STREAM: debug_assert(sm->GetVertexStream()->GetStream(_GEOM_STREAM).IsNull(), "model file error."); ReadTransStream(sm, stream); break; case MC_SUBMESH_LIGHT_STREAM: debug_assert(sm->GetVertexStream()->GetStream(_LIGHT_STREAM).IsNull(), "model file error."); ReadLightStream(sm, stream); break; case MC_SUBMESH_TEXCOORD_STREAM: debug_assert(sm->GetVertexStream()->GetStream(_TEXC_STREAM).IsNull(), "model file error."); ReadTexcStream(sm, stream); break; case MC_SUBMESH_ANIMATION_STREAM: debug_assert(sm->GetVertexStream()->GetStream(_ANIM_STREAM).IsNull(), "model file error."); ReadAnimStream(sm, stream); break; case MC_SUBMESH_INDEX_STREAM: debug_assert(sm->GetIndexStream()->GetStream().IsNull(), "model file error."); ReadIndexStream(sm, stream); break; } } decl->Init(); d_assert(sm->GetVertexStream()->GetStream(_GEOM_STREAM).NotNull()); //skip if (!stream->Eof()) stream->Skip(-MC_CHUNK_SIZE); }