コード例 #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
ファイル: 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();
}
コード例 #3
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();
}
コード例 #4
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();
}
コード例 #5
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();
}
コード例 #6
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();
}