コード例 #1
0
ファイル: DecalSet.cpp プロジェクト: TheComet93/Urho3D
PODVector<unsigned char> DecalSet::GetDecalsAttr() const
{
    VectorBuffer ret;

    ret.WriteBool(skinned_);
    ret.WriteVLE(decals_.Size());

    for (List<Decal>::ConstIterator i = decals_.Begin(); i != decals_.End(); ++i)
    {
        ret.WriteFloat(i->timer_);
        ret.WriteFloat(i->timeToLive_);
        ret.WriteVLE(i->vertices_.Size());
        ret.WriteVLE(i->indices_.Size());

        for (PODVector<DecalVertex>::ConstIterator j = i->vertices_.Begin(); j != i->vertices_.End(); ++j)
        {
            ret.WriteVector3(j->position_);
            ret.WriteVector3(j->normal_);
            ret.WriteVector2(j->texCoord_);
            ret.WriteVector4(j->tangent_);
            if (skinned_)
            {
                for (unsigned k = 0; k < 4; ++k)
                    ret.WriteFloat(j->blendWeights_[k]);
                for (unsigned k = 0; k < 4; ++k)
                    ret.WriteUByte(j->blendIndices_[k]);
            }
        }

        for (PODVector<unsigned short>::ConstIterator j = i->indices_.Begin(); j != i->indices_.End(); ++j)
            ret.WriteUShort(*j);
    }

    if (skinned_)
    {
        ret.WriteVLE(bones_.Size());

        for (Vector<Bone>::ConstIterator i = bones_.Begin(); i != bones_.End(); ++i)
        {
            ret.WriteString(i->name_);
            ret.WriteUByte(i->collisionMask_);
            if (i->collisionMask_ & BONECOLLISION_SPHERE)
                ret.WriteFloat(i->radius_);
            if (i->collisionMask_ & BONECOLLISION_BOX)
                ret.WriteBoundingBox(i->boundingBox_);
            ret.Write(i->offsetMatrix_.Data(), sizeof(Matrix3x4));
        }
    }

    return ret.GetBuffer();
}
コード例 #2
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();
}