Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6216459
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T07:15:11+00:00 2026-05-24T07:15:11+00:00

I’m trying to serialize a b2World, and due to Box2D’s many private objects that

  • 0

I’m trying to serialize a b2World, and due to Box2D’s many private objects that are used, made, and deleted internally, the issue becomes much more complicated. I decided that i should use these internal objects get() functions to get the data i need, and create a “b2Definition” object based off it at save time, and use the definition with the global factories “create” methods to recreate the objects.

I have encountered a few problems i need help on however: In the following code is all the JointDef data i need, but can’t figure out how to get from the pointer to the correct type of object.

I also am wondering if i should even attempt to save contact data…. Is it automatically made in the factory create metods?

        b2WeldJointDef JointDef; //QUESTION: how do i get this
        //JointDef.referenceAngle=      Joint-> ?????       

        b2GearJointDef JointDef; //QUESTION: how do i get these
        //JointDef.joint1=              Joint-> ??????  
        //JointDef.joint2=              Joint-> ??????

        b2LineJointDef JointDef; //QUESTION: how do i get these??
        //JointDef.localAxisA=          Joint-> ????
        //JointDef.lowerTranslation=    Joint-> ????    
        //JointDef.upperTranslation=    Joint-> ????

        b2MouseJointDef JointDef; //No problems

        b2PrismaticJointDef JointDef; //QUESTION: how do i get these??
        //JointDef.referenceAngle=      Joint-> ????
        //JointDef.localAxis1=          Joint-> ????  
        //JointDef.lowerTranslation=    Joint-> ????                    //JointDef.upperTranslation=    Joint-> ????  
        //JointDef.maxMotorForce=       Joint-> ????

        b2PulleyJointDef JointDef; //QUESTION: how do i get these?
        //JointDef.maxLengthA=          Joint-> ????
        //JointDef.maxLengthB=          Joint-> ????    

        b2RevoluteJointDef JointDef; //QUESTION: how do i get these?
        //JointDef.maxMotorTorque=      Joint-> ????
        //JointDef.referenceAngle       Joint-> ????
        //JointDef.lowerAngle=          Joint-> ????    
        //JointDef.upperAngle=          Joint-> ????

        b2JointDef JointDef;
        //JointDef.collideConnected= ????   

Do i need the data above? Is there a way to get it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T07:15:11+00:00Added an answer on May 24, 2026 at 7:15 am

    I did a lot of this recently to make an export/import utility to serialize a Box2D world to JSON and then load it again. You may find the source code useful – check out http://www.iforce2d.net/b2djson Scroll towards the bottom and you can see the source code, look at the function b2dJson::b2j(b2Joint* joint)

    It’s not complicated, you just need to check the joint type and cast to a pointer of that type to access the contents:

    switch ( joint->GetType() )
    {
        case e_revoluteJoint:
        {
            b2RevoluteJoint* revoluteJoint = (b2RevoluteJoint*)joint;
            ...
        }
    }
    

    A few things to note though:

    • you will need to change the Box2D code itself to add some extra GetXXX() functions to the joints to get all the necessary info. I put a list of them on that page too so you can check what these were for my case (I was using the most recent svn)
    • joints hold a memory pointer to the bodies they join which is useless to serialize, so you will first need to serialize the bodies in the world, then give the joints an index in that list
    • joint defs take a reference angle but joints do not hold this after they are created, so you need to use the body angles and the joint angle to calculate what it was
    • gear joints join two other joints and these are held as memory pointers, so to recreate these you will need to first serialize all non-gear joints, then give the gear joints an index in that list
    • recently gear joints were changed so that they no longer keep the pointers to the two other joints they control, so you will need to add them back if you want to support gear joints with the most recent svn
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to create an if statement in PHP that prevents a single post
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I used javascript for loading a picture on my website depending on which small
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.