Skip to content

Serializable templates #46

@acaly

Description

@acaly

Hi,

I am wondering whether we can make the templates serializable, specifically, serializable with DataContractSerializer and BinaryFormatter. By storing the template in resources instead of hard-code in C# one by one, it will definitely make the built-in template more useful when we are serializing a game scene.

I am also wondering whether we can add a list/array of FixtureTemplate in BodyTemplate, which allows us to store only one BodyTemplate to create on body. Now we need to specify a BodyTemplate and attach several Fixtures. Also this does the same as FixtureTemplate, which contains a Shape (or ShapeTemplate, please below). The final goal is to make template easier to use, especially more friendly to game scene serialization.

If you think it's reasonable, I can make a pull request. This requires the following work:

  • Add attributes to classes and properties.
  • Add default constructors.
  • Change Shape in FixtureTemplate to ShapeTemplate, and Body to BodyTemplate in JointTemplate. Compared with their templates, Shape and Body are difficult to serialize.
  • Add an array of FixtureTemplate in BodyTemplate.
  • Add a helper function in Factory class to create Body and Joint objects in a World.

This may requires more tests, but I don't have a clear idea on how to do that yet. What are your suggestions?

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions