VariantVector DecalSet::GetDecalsAttr() const { VariantVector ret; ret.Push(skinned_); ret.Push(decals_.Size()); for (List<Decal>::ConstIterator i = decals_.Begin(); i != decals_.End(); ++i) { ret.Push(i->timer_); ret.Push(i->timeToLive_); ret.Push(i->vertices_.Size()); ret.Push(i->indices_.Size()); VectorBuffer geometry; for (PODVector<DecalVertex>::ConstIterator j = i->vertices_.Begin(); j != i->vertices_.End(); ++j) { geometry.WriteVector3(j->position_); geometry.WriteVector3(j->normal_); geometry.WriteVector2(j->texCoord_); geometry.WriteVector4(j->tangent_); if (skinned_) { for (unsigned k = 0; k < 4; ++k) geometry.WriteFloat(j->blendWeights_[k]); for (unsigned k = 0; k < 4; ++k) geometry.WriteUByte(j->blendIndices_[k]); } } for (PODVector<unsigned short>::ConstIterator j = i->indices_.Begin(); j != i->indices_.End(); ++j) geometry.WriteUShort(*j); ret.Push(geometry.GetBuffer()); } if (skinned_) { ret.Push(bones_.Size()); for (Vector<Bone>::ConstIterator i = bones_.Begin(); i != bones_.End(); ++i) { ret.Push(i->name_); VectorBuffer boneData; boneData.WriteUByte(i->collisionMask_); if (i->collisionMask_ & BONECOLLISION_SPHERE) boneData.WriteFloat(i->radius_); if (i->collisionMask_ & BONECOLLISION_BOX) boneData.WriteBoundingBox(i->boundingBox_); boneData.Write(i->offsetMatrix_.Data(), sizeof(Matrix3x4)); ret.Push(boneData.GetBuffer()); } } return ret; }
PODVector<unsigned char> DynamicNavigationMesh::GetNavigationDataAttr() const { VectorBuffer ret; if (navMesh_ && tileCache_) { ret.WriteBoundingBox(boundingBox_); ret.WriteInt(numTilesX_); ret.WriteInt(numTilesZ_); const dtNavMeshParams* params = navMesh_->getParams(); ret.Write(params, sizeof(dtNavMeshParams)); const dtTileCacheParams* tcParams = tileCache_->getParams(); ret.Write(tcParams, sizeof(dtTileCacheParams)); for (int z = 0; z < numTilesZ_; ++z) for (int x = 0; x < numTilesX_; ++x) WriteTiles(ret, x, z); } return ret.GetBuffer(); }
PODVector<unsigned char> NavigationMesh::GetNavigationDataAttr() const { VectorBuffer ret; if (navMesh_) { ret.WriteBoundingBox(boundingBox_); ret.WriteInt(numTilesX_); ret.WriteInt(numTilesZ_); const dtNavMeshParams* params = navMesh_->getParams(); ret.WriteFloat(params->tileWidth); ret.WriteFloat(params->tileHeight); ret.WriteInt(params->maxTiles); ret.WriteInt(params->maxPolys); const dtNavMesh* navMesh = navMesh_; for (int z = 0; z < numTilesZ_; ++z) { for (int x = 0; x < numTilesX_; ++x) { const dtMeshTile* tile = navMesh->getTileAt(x, z, 0); if (!tile) continue; ret.WriteInt(x); ret.WriteInt(z); ret.WriteUInt(navMesh->getTileRef(tile)); ret.WriteUInt((unsigned)tile->dataSize); ret.Write(tile->data, (unsigned)tile->dataSize); } } } return ret.GetBuffer(); }
PODVector<unsigned char> DynamicNavigationMesh::GetNavigationDataAttr() const { VectorBuffer ret; if (navMesh_ && tileCache_) { ret.WriteBoundingBox(boundingBox_); ret.WriteInt(numTilesX_); ret.WriteInt(numTilesZ_); const dtNavMeshParams* params = navMesh_->getParams(); ret.Write(params, sizeof(dtNavMeshParams)); const dtTileCacheParams* tcParams = tileCache_->getParams(); ret.Write(tcParams, sizeof(dtTileCacheParams)); for (int z = 0; z < numTilesZ_; ++z) { for (int x = 0; x < numTilesX_; ++x) { dtCompressedTileRef tiles[TILECACHE_MAXLAYERS]; const int ct = tileCache_->getTilesAt(x, z, tiles, TILECACHE_MAXLAYERS); for (int i = 0; i < ct; ++i) { const dtCompressedTile* tile = tileCache_->getTileByRef(tiles[i]); if (!tile || !tile->header || !tile->dataSize) continue; // Don't write "void-space" tiles // The header conveniently has the majority of the information required ret.Write(tile->header, sizeof(dtTileCacheLayerHeader)); ret.WriteInt(tile->dataSize); ret.Write(tile->data, tile->dataSize); } } } } return ret.GetBuffer(); }