void MeshLoader_v0::ReadSkeleton(MeshPtr mesh, DataStreamPtr & stream) { String sSkeletonName; stream->ReadString(sSkeletonName); TString128 Source = mesh->GetSourceName(); Source = File::GetFileDir(Source); if (Source == "") { Source = sSkeletonName.c_str(); } else { Source += "\\"; Source += sSkeletonName.c_str(); } SkeletonLoader::Load(mesh->GetSkeleton(), Source); //mesh->SetSkeletonName(sSkeletonName.c_str()); }
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); }