Bugs in 1.7.1

Report problems here (or use the built-in feedback dialog in the editor)
Post Reply
vizgl
Posts: 3
Joined: Tue Mar 24, 2015 3:20 pm

Bugs in 1.7.1

Post by vizgl »

I have found bugs in new version. Please fix it asap ;)

1) Open Tools->Options->Files
Uncheck item "Save full path for object files"
Save project file and open it in text editor, we still have full path to object rube file.

"metaobject" : [
{
...
"file" : "D:/rube-win32-1.7.1/rube-win32-1.7.1/circle.rube",
...
}
]

And another request, please add "path" ref to object into raw json file, it'w will be very usefull(I want bind real as3 class with rube object)

2) Create project "hero.rube", add some body and image, attach image to body and save project.
Create another project, say "level.rube" and add "hero.rube" as object, save it as raw json.
Image from "hero.rube" is not attached to body from "hero.rube" it has body=-1
iforce2d
Site Admin
Posts: 861
Joined: Sat Dec 22, 2012 7:20 pm

Re: Bugs in 1.7.1

Post by iforce2d »

Hi vizgl

Thanks for the reports. I have fixed the problem with full paths always being used, you can build v1.7.2 now.
vizgl wrote: And another request, please add "path" ref to object into raw json file, it'w will be very usefull(I want bind real as3 class with rube object)
The path of objects is actually being exported, but nothing will be written if the path is empty (absence of a path property is interpreted as path = "", that is, no nested parent). You should see a "path" property for cases where objects are nested though. However, I would like to point out that this part of the export is not supported right now. So I have not mentioned this in the exported file format documentation, and I have not added any facility in b2dJson to use the "object" part of exported json files. The position, scale and angle properties are not very useful because they are relative to their parent, and there is no convenient way to traverse the structure and get the final transformed values. Custom properties are there though, which could be more useful. I want to have a better way to present this data in future, so the format may change a little which is why I'm not publicizing it right now.

What is supported now though, is getting the path of each item (body,joint,fixture,image) that was generated from an object instance. It's only in C++ b2dJson at the moment, but there are functions like getBodyPath, getBodiesByPath, getBodyByPathAndName. Perhaps you could pick one body from your object and get the path of it to use for your class matching.

I was not able to reproduce the other error you described, where the image was not attached to the body. Perhaps you had not yet saved the "hero.rube" with the image attached...? When objects are processed for export or for the player view, they use the file as it exists on disk. If you have a referenced object open in another view, you'll need to save it first before the changes will take effect in any references processed for that file.
vizgl
Posts: 3
Joined: Tue Mar 24, 2015 3:20 pm

Re: Bugs in 1.7.1

Post by vizgl »

iforce2d
I want to use object file path in my code.

When I save rube file I have this:

Code: Select all

    "metaobject" : 
    [
      
      {
        "angle" : 0,
        "file" : "circle.rube",
        "flip" : false,
        "id" : 1,
        "name" : "object0",
        "position" : 
        {
          "x" : 1.505710721015930,
          "y" : 0.7920212149620056
        },
        "scale" : 1
      }
    ],

But when I save raw json file, here is no field with path("file" : "circle.rube")

Code: Select all

	"object" : 
	[
		
		{
			"name" : "object0",
			"position" : 
			{
				"x" : 0.9006361961364746,
				"y" : 0.9337815642356873
			},
			"scale" : 1
		}
	],
I want to use this field in my code, so , please implements something like this, in raw json:

Code: Select all

	"object" : 
	[
		
		{
			"name" : "object0",
			"file":"circle.rube"
			"position" : 
			{
				"x" : 0.9006361961364746,
				"y" : 0.9337815642356873
			},
			"scale" : 1
		}
	],
iforce2d
Site Admin
Posts: 861
Joined: Sat Dec 22, 2012 7:20 pm

Re: Bugs in 1.7.1

Post by iforce2d »

I see. For now you can do that with a custom property, and you could use a script to create and set the property automatically:

Code: Select all

addCustomProperty('object','file','File','string');
object[] objs = ao();
for (uint i = 0; i < objs.length; i++) {
	string file = objs[i].getFile();
	file = file.substr( file.findLast('/') + 1 ); // discard path
	objs[i].setCustomString( 'file', file );
}
If you set that script to run in the "Before export" hook, you'll never need to manually set anything more.
vizgl
Posts: 3
Joined: Tue Mar 24, 2015 3:20 pm

Re: Bugs in 1.7.1

Post by vizgl »

iforce2d wrote:I see. For now you can do that with a custom property, and you could use a script to create and set the property automatically:

Code: Select all

addCustomProperty('object','file','File','string');
object[] objs = ao();
for (uint i = 0; i < objs.length; i++) {
	string file = objs[i].getFile();
	file = file.substr( file.findLast('/') + 1 ); // discard path
	objs[i].setCustomString( 'file', file );
}
If you set that script to run in the "Before export" hook, you'll never need to manually set anything more.
Great, thanks 8-)
Post Reply