static bool decodeRig(fsMsgRig &_msg, const std::string &buffer, Size &start) { bool success = true; success &= read_vector(_msg.mesh().m_quads,buffer,start); // read quads success &= read_vector(_msg.mesh().m_tris,buffer,start); // read triangles success &= read_vector(_msg.mesh().m_vertex_data.m_vertices,buffer,start);// read neutral vertices success &= read_small_vector(_msg.blendshape_names(),buffer,start); // read names uint16_t bsize = 0; success &= read_pod(bsize,buffer,start); _msg.blendshapes().resize(bsize); for(uint16_t i = 0;i < bsize; i++) success &= read_vector(_msg.blendshapes()[i].m_vertices,buffer,start); // read blendshapes return success; }
void BlendFace::setRig(const fsMsgRig& rig) { // convert to FBX geometry FBXGeometry geometry; for (vector<fsVector4i>::const_iterator it = rig.mesh().m_quads.begin(), end = rig.mesh().m_quads.end(); it != end; it++) { geometry.quadIndices.append(it->x); geometry.quadIndices.append(it->y); geometry.quadIndices.append(it->z); geometry.quadIndices.append(it->w); } for (vector<fsVector3i>::const_iterator it = rig.mesh().m_tris.begin(), end = rig.mesh().m_tris.end(); it != end; it++) { geometry.triangleIndices.append(it->x); geometry.triangleIndices.append(it->y); geometry.triangleIndices.append(it->z); } for (vector<fsVector3f>::const_iterator it = rig.mesh().m_vertex_data.m_vertices.begin(), end = rig.mesh().m_vertex_data.m_vertices.end(); it != end; it++) { geometry.vertices.append(glm::vec3(it->x, it->y, it->z)); } for (vector<fsVertexData>::const_iterator it = rig.blendshapes().begin(), end = rig.blendshapes().end(); it != end; it++) { FBXBlendshape blendshape; for (int i = 0, n = it->m_vertices.size(); i < n; i++) { // subtract the base vertex position; we want the deltas blendshape.vertices.append(createVec3(it->m_vertices[i]) - geometry.vertices[i]); blendshape.indices.append(i); } geometry.blendshapes.append(blendshape); } setGeometry(geometry); }
void fsBinaryStream::encode_message(std::string &msg_out, const fsMsgRig &msg) { Size start = msg_out.size(); BlockHeader header(msg.id()); write_pod(msg_out, header); write_vector(msg_out, msg.mesh().m_quads); // write quads write_vector(msg_out, msg.mesh().m_tris);// write triangles write_vector(msg_out, msg.mesh().m_vertex_data.m_vertices);// write neutral vertices write_small_vector(msg_out, msg.blendshape_names());// write names write_pod(msg_out,uint16_t(msg.blendshapes().size())); for(uint16_t i = 0;i < uint16_t(msg.blendshapes().size()); i++) write_vector(msg_out, msg.blendshapes()[i].m_vertices); // write blendshapes update_msg_size(msg_out, start); }