axes of coordinates R.U.B.E to box2d sdl2
-
- Posts: 25
- Joined: Tue Sep 19, 2017 4:30 pm
axes of coordinates R.U.B.E to box2d sdl2
How to adjust the program to the correct axes ??? I Have to do the FLIP for proper display and placement of the object in the game
Re: axes of coordinates R.U.B.E to box2d sdl2
Have you looked at the example SDL2 loader? Maybe it will help:
https://www.iforce2d.net/rube/?panel=loaders
These threads may also be relevant:
viewtopic.php?f=6&t=542
viewtopic.php?f=6&t=291
viewtopic.php?f=6&t=49
https://www.iforce2d.net/rube/?panel=loaders
These threads may also be relevant:
viewtopic.php?f=6&t=542
viewtopic.php?f=6&t=291
viewtopic.php?f=6&t=49
-
- Posts: 25
- Joined: Tue Sep 19, 2017 4:30 pm
Re: axes of coordinates R.U.B.E to box2d sdl2
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?
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
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.
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.
-
- Posts: 25
- Joined: Tue Sep 19, 2017 4:30 pm
Re: axes of coordinates R.U.B.E to box2d sdl2
In an example rube-C++-sample-SDL2:
if i try to creat another object:
It is to make ERROR in b2BlockAllocator.cpp:
line 112
I think that i must do all objects in one *.json file like LEVEL... but it isn't good idea.
Code: Select all
b2World* World;
World= car.readFromFile("car.json", errorMsg);
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.
-
- Posts: 25
- Joined: Tue Sep 19, 2017 4:30 pm
Re: axes of coordinates R.U.B.E to box2d sdl2
I try loader from rube-C++-sample-SDL2
and got:
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.
and got:
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.
-
- Posts: 25
- Joined: Tue Sep 19, 2017 4:30 pm
Re: axes of coordinates R.U.B.E to box2d sdl2
No rotate... Need flip body, how it do
Re: axes of coordinates R.U.B.E to box2d sdl2
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
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
-
- Posts: 25
- Joined: Tue Sep 19, 2017 4:30 pm
Re: axes of coordinates R.U.B.E to box2d sdl2
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
and 2 question - answer - viewtopic.php?f=6&t=176
-
- Posts: 25
- Joined: Tue Sep 19, 2017 4:30 pm
Re: axes of coordinates R.U.B.E to box2d sdl2
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