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();
}
Пример #2
0
//
// write_node
//
void ClientSidePrediction::write_node(VectorBuffer& message, Node& node)
{
    // Write node ID
    message.WriteUInt(node.GetID());

    // Write attributes
    write_network_attributes(node, message);

    // Write user variables
    const auto& vars = node.GetVars();
    message.WriteVLE(vars.Size());
    for (auto i = vars.Begin(); i != vars.End(); ++i)
    {
        message.WriteStringHash(i->first_);
        message.WriteVariant(i->second_);
    }

    // Write number of components
    message.WriteVLE(node.GetNumComponents());

    // Write components
    const auto& components = node.GetComponents();
    for (unsigned i = 0; i < components.Size(); ++i)
    {
        auto component = components[i];
        write_component(message, *component);
    }
}
Пример #3
0
//
// write_component
//
void ClientSidePrediction::write_component(VectorBuffer& message, Component& component)
{
    // Write ID
    message.WriteUInt(component.GetID());
    // Write type
    message.WriteStringHash(component.GetType());
    // Write attributes
    write_network_attributes(component, message);
}
Пример #4
0
//
// write_scene_state
//
void ClientSidePrediction::write_scene_state(VectorBuffer& message, Scene* scene)
{
    // Write placeholder last input ID, which will be set per connection before sending
    message.WriteUInt(0);

    auto& nodes = scene_nodes[scene];

    // Write number of nodes
    message.WriteVLE(nodes.size());

    // Write nodes
    for (auto node : nodes)
        write_node(message, *node);
}
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();
}