Пример #1
0
    void GravityWell::ProtoDeSerializeProperties(const XML::Node& SelfRoot)
    {
        this->AreaEffect::ProtoDeSerializeProperties(SelfRoot);

        XML::Attribute CurrAttrib;
        XML::Node PropertiesNode = SelfRoot.GetChild( GravityWell::GetSerializableName() + "Properties" );

        if( !PropertiesNode.Empty() ) {
            if(PropertiesNode.GetAttribute("Version").AsInt() == 1) {
                CurrAttrib = PropertiesNode.GetAttribute("AttenAmount");
                if( !CurrAttrib.Empty() )
                    this->SetAttenuationAmount( CurrAttrib.AsReal() );

                CurrAttrib = PropertiesNode.GetAttribute("AttenStyle");
                if( !CurrAttrib.Empty() )
                    this->SetAttenuationStyle( static_cast<Mezzanine::AttenuationStyle>( CurrAttrib.AsWhole() ) );

                CurrAttrib = PropertiesNode.GetAttribute("Strength");
                if( !CurrAttrib.Empty() )
                    this->SetFieldStrength( CurrAttrib.AsReal() );

                CurrAttrib = PropertiesNode.GetAttribute("AllowWorldGravity");
                if( !CurrAttrib.Empty() )
                    this->SetAllowWorldGravity( StringTools::ConvertToBool( CurrAttrib.AsString() ) );
            }else{
                MEZZ_EXCEPTION(ExceptionBase::INVALID_VERSION_EXCEPTION,"Incompatible XML Version for " + (GravityWell::GetSerializableName() + "Properties" ) + ": Not Version 1.");
            }
        }else{
            MEZZ_EXCEPTION(ExceptionBase::II_IDENTITY_NOT_FOUND_EXCEPTION,GravityWell::GetSerializableName() + "Properties" + " was not found in the provided XML node, which was expected.");
        }
    }
Пример #2
0
        ConeCollisionShape::ConeCollisionShape(XML::Node OneNode)
        {
            if(OneNode.GetAttribute("Version").AsInt() == 1)
            {
                XML::Attribute OneName = OneNode.GetChild("PrimitiveCollisionShape").GetChild("CollisionShape").GetAttribute("Name");               // get name
                if(!OneName) { MEZZ_EXCEPTION(Exception::PARAMETERS_EXCEPTION,"Could not find Name Attribute on CollsionShape Node during preparation for deserialization"); }
                String Name_(OneName.AsString());

                XML::Attribute Radius = OneNode.GetAttribute("Radius");                                                                             // Find Attributes
                if (!Radius) { DeSerializeError("find Radius Attribute",ConeCollisionShape::SerializableName()); }
                XML::Attribute Axis = OneNode.GetAttribute("Axis");
                if (!Axis) { DeSerializeError("find Axis Attribute",ConeCollisionShape::SerializableName()); }
                XML::Attribute Height = OneNode.GetAttribute("Height");
                if (!Height) { DeSerializeError("find Height Attribute",ConeCollisionShape::SerializableName()); }

                this->Construct(Name_,Radius.AsReal(),Height.AsReal(), (StandardAxis)Axis.AsInteger());        // make and deserialize the shape
                this->ProtoDeSerialize(OneNode);
            }else{
                DeSerializeError("find usable serialization version",ConeCollisionShape::SerializableName());
            }
        }
Пример #3
0
        void SliderConstraint::ProtoDeSerializeProperties(const XML::Node& SelfRoot)
        {
            this->Constraint::ProtoDeSerializeProperties(SelfRoot);

            XML::Attribute CurrAttrib;
            XML::Node PropertiesNode = SelfRoot.GetChild( SliderConstraint::GetSerializableName() + "Properties" );

            if( !PropertiesNode.Empty() ) {
                if( PropertiesNode.GetAttribute("Version").AsInt() == 1 ) {
                    CurrAttrib = PropertiesNode.GetAttribute("UseFrameOffset");
                    if( !CurrAttrib.Empty() )
                        this->SetUseFrameOffset( CurrAttrib.AsBool() );

                    CurrAttrib = PropertiesNode.GetAttribute("UpperLinLimit");
                    if( !CurrAttrib.Empty() )
                        this->SetUpperLinLimit( CurrAttrib.AsReal() );

                    CurrAttrib = PropertiesNode.GetAttribute("UpperAngLimit");
                    if( !CurrAttrib.Empty() )
                        this->SetUpperAngLimit( CurrAttrib.AsReal() );

                    CurrAttrib = PropertiesNode.GetAttribute("LowerLinLimit");
                    if( !CurrAttrib.Empty() )
                        this->SetLowerLinLimit( CurrAttrib.AsReal() );

                    CurrAttrib = PropertiesNode.GetAttribute("LowerAngLimit");
                    if( !CurrAttrib.Empty() )
                        this->SetLowerAngLimit( CurrAttrib.AsReal() );

                    CurrAttrib = PropertiesNode.GetAttribute("PoweredLinMotor");
                    if( !CurrAttrib.Empty() )
                        this->SetPoweredLinMotor( CurrAttrib.AsBool() );

                    CurrAttrib = PropertiesNode.GetAttribute("PoweredAngMotor");
                    if( !CurrAttrib.Empty() )
                        this->SetPoweredAngMotor( CurrAttrib.AsBool() );

                    CurrAttrib = PropertiesNode.GetAttribute("TargetLinMotorVelocity");
                    if( !CurrAttrib.Empty() )
                        this->SetTargetLinMotorVelocity( CurrAttrib.AsReal() );

                    CurrAttrib = PropertiesNode.GetAttribute("TargetAngMotorVelocity");
                    if( !CurrAttrib.Empty() )
                        this->SetTargetAngMotorVelocity( CurrAttrib.AsReal() );

                    CurrAttrib = PropertiesNode.GetAttribute("MaxLinMotorForce");
                    if( !CurrAttrib.Empty() )
                        this->SetMaxLinMotorForce( CurrAttrib.AsReal() );

                    CurrAttrib = PropertiesNode.GetAttribute("MaxAngMotorForce");
                    if( !CurrAttrib.Empty() )
                        this->SetMaxAngMotorForce( CurrAttrib.AsReal() );

                    CurrAttrib = PropertiesNode.GetAttribute("SoftnessLimLin");
                    if( !CurrAttrib.Empty() )
                        this->SetSoftnessLimLin( CurrAttrib.AsReal() );

                    CurrAttrib = PropertiesNode.GetAttribute("SoftnessLimAng");
                    if( !CurrAttrib.Empty() )
                        this->SetSoftnessLimAng( CurrAttrib.AsReal() );

                    CurrAttrib = PropertiesNode.GetAttribute("SoftnessOrthoLin");
                    if( !CurrAttrib.Empty() )
                        this->SetSoftnessOrthoLin( CurrAttrib.AsReal() );

                    CurrAttrib = PropertiesNode.GetAttribute("SoftnessOrthoAng");
                    if( !CurrAttrib.Empty() )
                        this->SetSoftnessOrthoAng( CurrAttrib.AsReal() );
                }else{
                    MEZZ_EXCEPTION(ExceptionBase::INVALID_VERSION_EXCEPTION,"Incompatible XML Version for " + ( SliderConstraint::GetSerializableName() + "Properties" ) + ": Not Version 1.");
                }
            }else{
                MEZZ_EXCEPTION(ExceptionBase::II_IDENTITY_NOT_FOUND_EXCEPTION,SliderConstraint::GetSerializableName() + "Properties" + " was not found in the provided XML node, which was expected.");
            }
        }