Page 1 of 1
axes of coordinates R.U.B.E to box2d sdl2
Posted: Thu Oct 05, 2017 5:38 pm
by FLYNSXCOOL
Re: axes of coordinates R.U.B.E to box2d sdl2
Posted: Fri Oct 06, 2017 9:12 am
by iforce2d
Re: axes of coordinates R.U.B.E to box2d sdl2
Posted: Fri Oct 06, 2017 4:32 pm
by FLYNSXCOOL
1) will I need to make the likeness as in the example?
2) did the example contains ready b2dJson ??
3) I took here
https://github.com/iforce2d/b2dJson for C++, maybe I need to change some file and not try to move from rube-C++-sample-SDL2 in my project. What do you think about this?
Re: axes of coordinates R.U.B.E to box2d sdl2
Posted: Sat Oct 07, 2017 5:43 pm
by iforce2d
1. No.
2. Yes of course, that is the whole point of having an example.
3. I would start with the example and work from there. Or at least, take a look at how the example does things and maybe you can modify your existing code a little.
Re: axes of coordinates R.U.B.E to box2d sdl2
Posted: Sun Oct 08, 2017 6:58 am
by FLYNSXCOOL
In an example
rube-C++-sample-SDL2:
Code: Select all
b2World* World;
World= car.readFromFile("car.json", errorMsg);
if i try to creat another object:
Code: Select all
b2Body *body;
b2BodyDef bdefw;
b2FixtureDef fdef;
b2PolygonShape rectb;
bdefw.angle = (float) (angl*M_PI/180);
bdefw.position.Set((float32) x/SCALE, (float32) y/SCALE);
rectb.SetAsBox((float32) w * 0.5 / SCALE, (float32) (h * 0.5 / SCALE));
body = World->CreateBody(&bdefw);
fdef.shape = &rectb;
fdef.friction = 0.0f;
body->CreateFixture(&fdef);
body = World->CreateBody(&bdefw);
It is to make
ERROR in b2BlockAllocator.cpp:
line 112
Code: Select all
if (m_freeLists[index])
{
b2Block* block = m_freeLists[index];
m_freeLists[index] = block->next;
return block;
}
I think that i must do all objects in one *.json file like LEVEL... but it isn't good idea.
Re: axes of coordinates R.U.B.E to box2d sdl2
Posted: Sun Oct 08, 2017 11:58 am
by FLYNSXCOOL
I try loader from
rube-C++-sample-SDL2
and got:

- Screenshot_1.png (81.01 KiB) Viewed 116567 times
I dont use b2dJsonImage_SDL2 ( SDL_Rect texr; texr.w = (int)(w * aspectScale * s * (flip?-1.0f:1.0f));), I have made exactly the same (use setScale(-1, -1);) for image
But I have not found in
rube-C++-sample-SDL2 how to deploy all of the
body
summing up..
1) loader from
rube-C++-sample-SDL2 - i must do all objects in one *.json file like LEVEL.. and i cant throw new object to world.
rube-C++-sample-SDL2 code have flip for image and i can rotate body to 180 for normal position.
2)
https://github.com/iforce2d/b2dJson for C++ - i can load level and i can load to level new objects but this code havent flip for image and i must similarly rotate body to 180 for normal position.
............................................
I understand how to deploy an one object (one сentral body) but do not understand how to deploy the entire level, relative to the centre (0,0) of the axes.
Re: axes of coordinates R.U.B.E to box2d sdl2
Posted: Mon Oct 09, 2017 3:12 am
by FLYNSXCOOL
No rotate... Need flip body, how it do
Re: axes of coordinates R.U.B.E to box2d sdl2
Posted: Tue Oct 10, 2017 11:28 am
by iforce2d
What line of that code causes the b2BlockAllocator crash? Is it the World->CreateBody line? Is the World variable valid?
The recommended method for merging multiple RUBE scenes into one world at runtime is shown on the main b2dJson page:
http://www.iforce2d.net/b2djson/#merging
I don't understand what you mean in your point number 2. Are you saying that the SDL2 example is displaying things flipped the wrong way for you?
I would recommend that your level is created relative to 0,0 so that it does not need to be moved. Load the level first. Then when you load each object into the world, move the objects as necessary. To move them, all bodies in the incoming object must be moved. Eg.
https://www.iforce2d.net/forums/viewtopic.php?f=6&t=379
Re: axes of coordinates R.U.B.E to box2d sdl2
Posted: Thu Oct 12, 2017 3:57 pm
by FLYNSXCOOL
I came out of the situation by making two versions of the body. One body, one facing left, another body is facing right, then turn them 180 ° and use loader json for C++, not SDL
and 2 question - answer -
viewtopic.php?f=6&t=176
Re: axes of coordinates R.U.B.E to box2d sdl2
Posted: Thu Oct 12, 2017 5:12 pm
by FLYNSXCOOL
BUT that would load the level will have to rotate them upside-down in the program R. U. B. E and turn on the X-axis