Exemple #1
0
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;
}
Exemple #2
0
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();
}
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();
}