My requests

What would you like to see in future versions of the editor?
tescott
Posts: 68
Joined: Wed Feb 06, 2013 6:32 pm

My requests

Post by tescott »

- Layers (covered elsewhere)

- Snap to grid (covered elsewhere)

- Enumerated type custom property. I'd like to have the ability to create a list of values that can be selected via a drop-down. Right now, I'm using a custom string property which kinda sorta gets me to where I want, but the enforcement of correct string values can only be done at run-time. In other words... I'm setting myself up for fail if I introduce a typo.

- Expanded filter category bit and mask bit handling. Right now it's limited to int values. Ideally I'd like to see a table of 16 checkboxes, one for each bit, that can be named at a global level and then selected individually. An additional 17th checkbox that allows you to toggle all on / all off would also be useful. Maybe include a view toggle that allows you to cycle between representations: Int > 16-bit hexadecimal > Individual Checkboxes.

- Quick one-keystroke method of flipping fixtures horizontally or vertically
tescott
Posts: 68
Joined: Wed Feb 06, 2013 6:32 pm

Re: My requests

Post by tescott »

More requests... These deal with trying to reduce the overall JSON output size.

- Ability to specify precision on output JSON data globally with field specific overrides. I have a friction value of 0.2 set for my fixtures. The related output value in JSON is "0.2000000029802322". This is for each fixture. Oy!

(Deleted other requests since the jq utility can satisfy them.)
Last edited by tescott on Mon Mar 04, 2013 2:18 am, edited 1 time in total.
tescott
Posts: 68
Joined: Wed Feb 06, 2013 6:32 pm

Re: My requests

Post by tescott »

I just discovered "jq":

http://stedolan.github.com/jq/

An extremely quick test:

jq --compact-output "." < palm.json > palm2.json

palm.json, size=159689
palm2.json, size=61293

Wow! My JSON Rube loader worked just fine on the palm2 output. Awesome! :)

Now to figure out how to make filters to strip out unwanted fields.

--tim
tescott
Posts: 68
Joined: Wed Feb 06, 2013 6:32 pm

Re: My requests

Post by tescott »

After reading up on jq, I came up with the following filter config:

jq -c "{allowSleep,autoClearForces,continuousPhysics,customProperties,gravity,positionIterations,stepsPerSecond,subStepping,velocityIterations,warmStarting,image:[.image[]|{angle,body,center,corners,customProperties,file}],body:[.body[]|{angle,awake,customProperties,fixture,position,type,fixture:[.fixture[]|{customProperties,density,friction,polygon}]}]}" < palm.json

This strips out several unused properties (at least, by my app). The result weighed in at 55777 bytes. Only a net savings of around 6k over just running jq with the -c option.

--tim
iforce2d
Site Admin
Posts: 861
Joined: Sat Dec 22, 2012 7:20 pm

Re: My requests

Post by iforce2d »

Nice utility! I have been using this one, it does an ok job but I think jq is better: http://fmarcia.info/jsmin/test.html

I have had a few requests about being able to exclude some of the image info properties (eg. corners, glVertexPointer etc) from the JSON, so I will add a means to do ignore properties, as a per-scene setting.
tescott
Posts: 68
Joined: Wed Feb 06, 2013 6:32 pm

Re: My requests

Post by tescott »

- Would it be possible to emit the "Flip" boolean parameter from image data to the .JSON file? I'm not seeing it appear in my output. I assume it is probably affecting some of the gl data that is listed in the output. However, I'm not using this in my game code.

- Adding a color tint for images would be great. I've got a custom String parameter that I'm using right now that includes r,g,b,a info that gets interpreted at run-time.
iforce2d
Site Admin
Posts: 861
Joined: Sat Dec 22, 2012 7:20 pm

Re: My requests

Post by iforce2d »

tescott wrote:- Would it be possible to emit the "Flip" boolean parameter from image data to the .JSON file? I'm not seeing it appear in my output. I assume it is probably affecting some of the gl data that is listed in the output. However, I'm not using this in my game code.

- Adding a color tint for images would be great. I've got a custom String parameter that I'm using right now that includes r,g,b,a info that gets interpreted at run-time.
Two excellent ideas, consider them done. Actually I was not aware that the 'flip' property was not being output, my bad.
iforce2d
Site Admin
Posts: 861
Joined: Sat Dec 22, 2012 7:20 pm

Re: My requests

Post by iforce2d »

Actually, just checking the source code now, the 'flip' property will be output if is true. If it is not present, you can consider it to be false. I will make it output regardless of the value.
tescott
Posts: 68
Joined: Wed Feb 06, 2013 6:32 pm

Re: My requests

Post by tescott »

Makes sense. I just noticed it was missing from the output and didn't even try to toggle things to see if would appear. Doh!

--tim
tescott
Posts: 68
Joined: Wed Feb 06, 2013 6:32 pm

Re: My requests

Post by tescott »

In the "JSON File structure" section of the RUBE help, you have the following:
  • Boolean values that do not exist in the JSON are implicitly false.
  • Numerical values that do not exist in the JSON are implicitly zero.
  • String values that do not exist in the JSON are implicitly empty strings.
  • Properties that are expected to be a vector but are numeric zero, are the vector (0,0).
  • Properties that are expected to be numerical but are strings should be interpreted as the hexadecimal representation of a 32-bit floating point number. This is done to preserve accuracy and decrease file size (average case). See the floatToHex/hexToFloat functions in the b2dJson source code for an implementation of converting these in C++. (You can disable the saving of floating point numbers as hexadecimal under the File tab of the Options dialog.)
If you were to change it so "flip" is always output, you'd be violating this idea. The reason I ask is that I'm seeing problems with handling vectors that are set to 0 vs (0,0) in JSON. The code I'm running uses a try / catch for this. If it fails to read a simple float (0), it hits the catch and assumes that a vector is defined. This works great, but ends up emitting a massive amount of warnings on the target device which I'd really like to clean up.

My preference would be that anything that is not present in the JSON output follows your rules above. Additionally, I'd prefer if (0,0) vectors simply didn't appear. Maybe include a "JSON output long form" / "JSON output short form" preference? Long-form spits out everything. Short-form condenses things down as much as possible.

--tim
Post Reply