コード例 #1
0
ファイル: DecalSet.cpp プロジェクト: acremean/urho3d
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;
}
コード例 #2
0
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();
}
コード例 #3
0
std::vector<unsigned char> CollisionChain2D::GetVerticesAttr() const
{
    VectorBuffer ret;

    for (unsigned i = 0; i < vertices_.size(); ++i)
        ret.WriteVector2(vertices_[i]);

    return ret.GetBuffer();
}
コード例 #4
0
ファイル: CrowdAgent.cpp プロジェクト: hendradarwin/Urho3D
PODVector<unsigned char> CrowdAgent::GetAgentDataAttr() const
{
    const dtCrowdAgent* agent = GetDetourCrowdAgent();
    if (!agent)
        return Variant::emptyBuffer;

    // Reading it back in isn't this simple, see SetAgentDataAttr
    VectorBuffer ret;
    ret.Write(agent, sizeof(dtCrowdAgent));

    return ret.GetBuffer();
}
コード例 #5
0
PODVector<unsigned char> CrowdAgent::GetAgentDataAttr() const
{
    if (!inCrowd_ || !crowdManager_ || !IsEnabled())
        return Variant::emptyBuffer;
    dtCrowd* crowd = crowdManager_->GetCrowd();
    const dtCrowdAgent* agent = crowd->getAgent(agentCrowdId_);
    
    // Reading it back in isn't this simple, see SetAgentDataAttr
    VectorBuffer ret;
    ret.Write(agent, sizeof(dtCrowdAgent));

    return ret.GetBuffer();
}
コード例 #6
0
ファイル: ScriptInstance.cpp プロジェクト: acremean/urho3d
PODVector<unsigned char> ScriptInstance::GetScriptDataAttr() const
{
    if (!scriptObject_ || !methods_[METHOD_SAVE])
        return PODVector<unsigned char>();
    else
    {
        VectorBuffer buf;
        VariantVector parameters;
        parameters.Push(Variant((void*)static_cast<Serializer*>(&buf)));
        scriptFile_->Execute(scriptObject_, methods_[METHOD_SAVE], parameters);
        return buf.GetBuffer();
    }
}
コード例 #7
0
ファイル: ScriptInstance.cpp プロジェクト: acremean/urho3d
PODVector<unsigned char> ScriptInstance::GetDelayedMethodCallsAttr() const
{
    VectorBuffer buf;
    buf.WriteVLE(delayedMethodCalls_.Size());
    for (Vector<DelayedMethodCall>::ConstIterator i = delayedMethodCalls_.Begin(); i != delayedMethodCalls_.End(); ++i)
    {
        buf.WriteFloat(i->period_);
        buf.WriteFloat(i->delay_);
        buf.WriteBool(i->repeat_);
        buf.WriteString(i->declaration_);
        buf.WriteVariantVector(i->parameters_);
    }
    return buf.GetBuffer();
}
コード例 #8
0
ファイル: LuaScriptInstance.cpp プロジェクト: janfrost/Urho3D
PODVector<unsigned char> LuaScriptInstance::GetScriptNetworkDataAttr() const
{
    if (scriptObjectRef_ == LUA_REFNIL)
        return PODVector<unsigned char>();

    VectorBuffer buf;

    WeakPtr<LuaFunction> function = scriptObjectMethods_[LSOM_WRITENETWORKUPDATE];
    if (function && function->BeginCall(this))
    {
        function->PushUserType((Serializer&)buf, "Serializer");
        function->EndCall();
    }

    return buf.GetBuffer();
}
コード例 #9
0
ファイル: PvPGM.cpp プロジェクト: practicing01/DotsNetCrits
void PvPGM::RequestMechanicExecution(Node* receiver, VectorBuffer& mechanicParams)
{
	const PODVector<unsigned char>& data = mechanicParams.GetBuffer();
	MemoryBuffer msg(data);

	for (int x = 0; x < players_.Size(); x++)
	{
		if (players_[x]->player_ == receiver)
		{
			((GameMechanic*)(players_[x]))->message_ = &msg;
			((GameMechanic*)(players_[x]))->clientID_ = ((GameMechanic*)(players_[x]))->clientIDSelf_;
			((GameMechanic*)(players_[x]))->lagTime_ = 0.0f;
			players_[x]->RequestMechanicExecute();
			break;
		}
	}
}
コード例 #10
0
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();
}
コード例 #11
0
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();
}
コード例 #12
0
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();
}
コード例 #13
0
PODVector<unsigned char> DynamicNavigationMesh::GetTileData(const IntVector2& tile) const
{
    VectorBuffer ret;
    WriteTiles(ret, tile.x_, tile.y_);
    return ret.GetBuffer();
}