void CollisionSeq::writeCollsionData(YAMLWriter& writer, std::shared_ptr<const CollisionLinkPairList> ptr)
{
    writer.startMapping();
    writer.putKey("LinkPairs");

    writer.startListing();
    for(auto it = ptr->begin(); it != ptr->end(); ++it){
        CollisionLinkPairPtr linkPair = *it;
        writer.startMapping();
        writer.putKeyValue("body0",linkPair->body[0]->name());
        writer.putKeyValue("link0",linkPair->link[0]->name());
        writer.putKeyValue("body1",linkPair->body[1]->name());
        writer.putKeyValue("link1",linkPair->link[1]->name());
        int numCollisions = linkPair->collisions.size();
        writer.putKey("Collisions");
        writer.startListing();
        for(int j=0; j<numCollisions; j++){
            Collision& collision = linkPair->collisions[j];
            writer.startFlowStyleListing();
            const Vector3& point = collision.point;
            writer.putScalar(point.x());
            writer.putScalar(point.y());
            writer.putScalar(point.z());
            const Vector3& normal = collision.normal;
            writer.putScalar(normal.x());
            writer.putScalar(normal.y());
            writer.putScalar(normal.z());
            writer.putScalar(collision.depth);
            writer.endListing();
        }
        writer.endListing();
        writer.endMapping();
        }
    writer.endListing();

    writer.endMapping();
}
Exemple #2
0
bool AbstractSeq::doWriteSeq(YAMLWriter& writer, std::function<void()> additionalPartCallback)
{
    if(seqType_.empty()){
        if(contentName_.empty()){
            writer.putMessage(_("The type of the sequence to write is unknown.\n"));
        } else {
            writer.putMessage(format(_("The type of the {} sequence to write is unknown.\n"), contentName_));
        }
        return false;
    }

    const double frameRate = getFrameRate();
    if(frameRate <= 0.0){
        writer.putMessage(
            format(_("Frame rate {0} of {1} is invalid.\n"),
                   frameRate, (contentName_.empty() ? seqType_ : contentName_)));
        return false;
    }

    writer.startMapping();
    
    writer.putKeyValue("type", seqType_);
    if(!contentName_.empty()){
        writer.putKeyValue("content", contentName_);
    }

    double version = writer.info("formatVersion", 0.0);
    if(version == 0.0 || !writer.info("isComponent", false)){
        writer.putKeyValue("formatVersion", version == 0.0 ? 2.0 : version);
    }
    writer.putKeyValue("frameRate", frameRate);
    writer.putKeyValue("numFrames", getNumFrames());

    if(additionalPartCallback) additionalPartCallback();

    writer.endMapping();
    
    return true;
}
Exemple #3
0
bool AbstractSeq::writeSeq(YAMLWriter& writer)
{
    bool result = false;
    
    if(seqType().empty()){
        addSeqMessage("setType() is empty.");

    } else {
        writer.startMapping();
        
        writer.putKeyValue("type", seqType());
        writer.putKeyValue("content", seqContentName());
        writer.putKeyValue("frameRate", getFrameRate());
        writer.putKeyValue("numFrames", getNumFrames());

        result = doWriteSeq(writer);

        writer.endMapping();
    }
    
    return result;
}