PODVector<unsigned char> CustomGeometry::GetGeometryDataAttr() const { VectorBuffer ret; ret.WriteVLE(geometries_.Size()); ret.WriteUInt(elementMask_); for (unsigned i = 0; i < geometries_.Size(); ++i) { unsigned numVertices = vertices_[i].Size(); ret.WriteVLE(numVertices); ret.WriteUByte(primitiveTypes_[i]); for (unsigned j = 0; j < numVertices; ++j) { if (elementMask_ & MASK_POSITION) ret.WriteVector3(vertices_[i][j].position_); if (elementMask_ & MASK_NORMAL) ret.WriteVector3(vertices_[i][j].normal_); if (elementMask_ & MASK_COLOR) ret.WriteUInt(vertices_[i][j].color_); if (elementMask_ & MASK_TEXCOORD1) ret.WriteVector2(vertices_[i][j].texCoord_); if (elementMask_ & MASK_TANGENT) ret.WriteVector4(vertices_[i][j].tangent_); } } return ret.GetBuffer(); }
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; }