コード例 #1
0
ファイル: actorrigid.cpp プロジェクト: zester/Mezzanine
    void ActorRigid::ProtoSerialize(XML::Node& CurrentRoot) const
    {
        XML::Node ActorNode = CurrentRoot.AppendChild("ActorRigid");
        if (!ActorNode) { ThrowSerialError("create ActorRigidNode");}

        XML::Attribute Version = ActorNode.AppendAttribute("Version");
        if (Version)
            { Version.SetValue(1); }
        else
            { SerializeError("Create set Version on ActorRigid node", SerializableName()); }

        XML::Attribute ActorName = ActorNode.AppendAttribute("Name");
            ActorName.SetValue(this->GetName());
        XML::Attribute ActorFile = ActorNode.AppendAttribute("File");
            ActorFile.SetValue(this->GraphicsObject->getMesh()->getName());
        XML::Attribute ActorGroup = ActorNode.AppendAttribute("Group");
            ActorGroup.SetValue(this->GraphicsObject->getMesh()->getGroup());
        if( !(ActorName && ActorFile && ActorGroup) )
            { ThrowSerialError("creating ActorRigid Attributes");}

        XML::Node LinearMovementFactor = ActorNode.AppendChild("LinearMovementFactor");
        if (!LinearMovementFactor) { ThrowSerialError("create LinearMovementFactor Node"); }
        this->GetLinearMovementFactor().ProtoSerialize(LinearMovementFactor);

        XML::Node AngularMovementFactor = ActorNode.AppendChild("AngularMovementFactor");
        if (!AngularMovementFactor) { ThrowSerialError("create AngularMovementFactor Node"); }
        this->GetAngularMovementFactor().ProtoSerialize(AngularMovementFactor);

        ActorBase::ProtoSerialize(ActorNode);
    }
コード例 #2
0
ファイル: gearconstraint.cpp プロジェクト: zester/Mezzanine
        void GearConstraint::ProtoSerialize(XML::Node& CurrentRoot) const
        {
            XML::Node P2PNode = CurrentRoot.AppendChild(this->GearConstraint::SerializableName());                     // The base node all the base constraint stuff will go in
            if (!P2PNode)
                { SerializeError("Create P2PNode", SerializableName()); }

            XML::Attribute VerAttr = P2PNode.AppendAttribute("Version");
            XML::Attribute RatioAttr = P2PNode.AppendAttribute("Ratio");

            if( VerAttr && RatioAttr )
            {
                VerAttr.SetValue(1);
                RatioAttr.SetValue(this->GetRotationRatio());
            }else{
                SerializeError("Create P2PNode Attributes", SerializableName());
            }

            XML::Node ActorANode = P2PNode.AppendChild("ActorA");
            if (!ActorANode)
                { SerializeError("Create ActorANode", SerializableName()); }
            this->GetAxisA().ProtoSerialize(ActorANode);

            XML::Node ActorBNode = P2PNode.AppendChild("ActorB");
            if (!ActorBNode)
                { SerializeError("Create ActorBNode", SerializableName()); }
            this->GetAxisB().ProtoSerialize(ActorBNode);

            this->Constraint::ProtoSerialize(P2PNode);
        }
コード例 #3
0
        void CapsuleCollisionShape::ProtoSerialize(XML::Node& CurrentRoot) const
        {
            XML::Node CollisionNode = CurrentRoot.AppendChild(this->CapsuleCollisionShape::SerializableName());
            if (!CollisionNode) { SerializeError("create CollisionNode",this->CapsuleCollisionShape::SerializableName());}

            XML::Attribute Version = CollisionNode.AppendAttribute("Version");
            if (Version)
                { Version.SetValue(1); }
            else
                { SerializeError("Create Version Attribute", SerializableName()); }
/*
            XML::Attribute RadiusAttr = CollisionNode.AppendAttribute("Radius");
            if (RadiusAttr)
                { RadiusAttr.SetValue(this->GetCleanRadius()); }
            else
                { SerializeError("Create RadiusAttr Attribute", SerializableName()); }

            XML::Attribute HeightAttr = CollisionNode.AppendAttribute("Height");
            if (HeightAttr)
                { HeightAttr.SetValue(this->GetCleanHeight()); }
            else
                { SerializeError("Create HeightAttr Attribute", SerializableName()); }
*/
            XML::Attribute AxisAttr = CollisionNode.AppendAttribute("Axis");
            if (AxisAttr)
                { AxisAttr.SetValue(this->GetUpStandardAxis()); }
            else
                { SerializeError("Create AxisAttr Attribute", SerializableName()); }

            this->PrimitiveCollisionShape::ProtoSerialize(CollisionNode);
        }
コード例 #4
0
ファイル: worldobject.cpp プロジェクト: zester/Mezzanine
    void WorldObject::ProtoSerialize(XML::Node& CurrentRoot) const
    {
        XML::Node WorldObjectNode = CurrentRoot.AppendChild("WorldObject");
        if (!WorldObjectNode) { ThrowSerialError("create WorldObjectNode");}

        XML::Node LocationNode = WorldObjectNode.AppendChild("Location");
        if (!LocationNode) { ThrowSerialError("create LocationNode"); }
        this->GetLocation().ProtoSerialize(LocationNode);

        XML::Node ScalingNode = WorldObjectNode.AppendChild("Scaling");
        if (!ScalingNode) { ThrowSerialError("create ScalingNode"); }
        this->GetScaling().ProtoSerialize(ScalingNode);

        this->GetGraphicsSettings()->ProtoSerialize(WorldObjectNode);
        this->GetPhysicsSettings()->ProtoSerialize(WorldObjectNode);

        XML::Attribute WorldObjectName = WorldObjectNode.AppendAttribute("Name");
            WorldObjectName.SetValue(this->GetName());
        XML::Attribute WorldObjectVersion = WorldObjectNode.AppendAttribute("Version");
            WorldObjectVersion.SetValue(1);
        XML::Attribute WorldObjectIsInWorld = WorldObjectNode.AppendAttribute("IsInWorld");
            WorldObjectIsInWorld.SetValue(this->IsInWorld());
        if ( !(WorldObjectName && WorldObjectVersion && WorldObjectIsInWorld) )
            { ThrowSerialError("create WorldObjectNode Attributes"); }

        /*XML::Attribute WorldObjectSoundSetName = WorldObjectNode.AppendAttribute("SoundSet");
        if(this->GetSounds())
        {
            WorldObjectSoundSetName.SetValue(this->GetSounds()->GetName());
        }else{
            WorldObjectSoundSetName.SetValue("");
        }//*/
    }
コード例 #5
0
ファイル: worldobject.cpp プロジェクト: zester/Mezzanine
    void NonStaticWorldObject::ProtoSerialize(XML::Node& CurrentRoot) const
    {
        XML::Node NonStaticWorldObjectNode = CurrentRoot.AppendChild("NonStaticWorldObject");
        if (!NonStaticWorldObjectNode) { ThrowSerialError("create NonStaticWorldObjectNode");}

        XML::Attribute Version = NonStaticWorldObjectNode.AppendAttribute("Version");
        Version.SetValue(1);

        XML::Node OrientationNode = NonStaticWorldObjectNode.AppendChild("Orientation");
        if(!OrientationNode)  { ThrowSerialError("create OrientationNode"); }

        this->GetOrientation().ProtoSerialize(OrientationNode);

        // if actor node is in scenemanager just save a name
        /*if( Entresol::GetSingletonPtr()->GetSceneManager()->GetNode( this->ObjectWorldNode->GetName() ) )
        {
            XML::Attribute NonStaticWorldObjectNodeAttrib = NonStaticWorldObjectNode.AppendAttribute("WorldNode");
            if(!NonStaticWorldObjectNodeAttrib.SetValue(this->ObjectWorldNode->GetName()))
                {ThrowSerialError("store WorldNode Name");}
        }else{
            SloppyProtoSerialize( *(this->ObjectWorldNode),NonStaticWorldObjectNode);                                   //Serialization performed in older style
        }// */

        WorldObject::ProtoSerialize(NonStaticWorldObjectNode);
    }
コード例 #6
0
ファイル: areaeffect.cpp プロジェクト: zester/Mezzanine
    void AreaEffect::ProtoSerialize(XML::Node& CurrentRoot) const
    {
        XML::Node AreaEffectNode = CurrentRoot.AppendChild("AreaEffect");
        if (!AreaEffectNode) { ThrowSerialError("create AreaEffectNode");}

        XML::Attribute AreaEffectVersion = AreaEffectNode.AppendAttribute("Version");
        AreaEffectVersion.SetValue(1);

        NonStaticWorldObject::ProtoSerialize(AreaEffectNode);
    }
コード例 #7
0
        void MeshCollisionShape::ProtoSerialize(XML::Node& CurrentRoot) const
        {
            XML::Node CollisionNode = CurrentRoot.AppendChild(this->MeshCollisionShape::GetSerializableName());
            if (!CollisionNode) { SerializeError("create CollisionNode",this->MeshCollisionShape::GetSerializableName());}

            XML::Attribute Version = CollisionNode.AppendAttribute("Version");
            if (Version)
                { Version.SetValue(1); }
            else
                { SerializeError("Create Version Attribute", GetSerializableName()); }

            this->CollisionShape::ProtoSerialize(CollisionNode);

        }
コード例 #8
0
        void CollisionShapeManager::SaveShapesToXMLFile(const String& FileName, ShapeVector& ShapesToSave)
        {
            XML::Document ShapesDoc;
            XML::Node DeclNode = ShapesDoc.AppendChild(XML::NodeDeclaration);
            XML::Attribute VerAttrib = DeclNode.AppendAttribute("version");

            if( DeclNode.SetName("xml") && VerAttrib.SetValue("1.0") ) {
                XML::Node ShapesRoot = ShapesDoc.AppendChild( "ShapesRoot" );
                for( ShapeVectorIterator ShapeIt = ShapesToSave.begin() ; ShapeIt != ShapesToSave.end() ; ++ShapeIt )
                {
                    (*ShapeIt)->ProtoSerialize( ShapesRoot );
                }

                /// @todo Replace this stack allocated stream for one initialized from the Resource Manager, after the system is ready.
                Resource::FileStream SettingsStream(FileName,".",Resource::SF_Truncate | Resource::SF_Write);
                ShapesDoc.Save(SettingsStream,"\t",XML::FormatIndent);
            }else{
                MEZZ_EXCEPTION(ExceptionBase::INVALID_STATE_EXCEPTION,"Failed to create XML document declaration for file \"" + FileName + "\".");
            }
        }