Hey,
i want to rotate a body not around his center, i want to rotate it around another point.
See this:

i rotate the background sprite with a definite sum around P( 400px | 300px ). While i do this the collision forms should rotate too, that they conform with the tiles you see. But the tiles rotate around their center, and the background sprite around P.
So they aren´t conform 🙁
Can someone help me? To rotate the collision forms i use
greetings Toa
EDIT:
Now i´m trying to rotate the body with my own function, see:
Is it possible that it does not work to change the vertices of the body while simulating?
i want to rotate a body not around his center, i want to rotate it around another point.
See this:

i rotate the background sprite with a definite sum around P( 400px | 300px ). While i do this the collision forms should rotate too, that they conform with the tiles you see. But the tiles rotate around their center, and the background sprite around P.
So they aren´t conform 🙁
Can someone help me? To rotate the collision forms i use
Code:
body->SetXForm( Pos, NewAngle );
greetings Toa
EDIT:
Now i´m trying to rotate the body with my own function, see:
Code:
void Game::CGeometry::RotateForms( double fRotation, Core::CVector vPos )
{
for ( set<CForm *>::iterator it = sForms.begin(); it != sForms.end(); ++it ) {
for ( b2Shape *ShapeList = (*it)->GetBody()->GetShapeList(); ShapeList; ShapeList = ShapeList->GetNext() ) {
if( ShapeList->GetType() == e_polygonShape ) {
b2PolygonDef* data = (*it)->GetShape();
for( unsigned int i = 0; i < data->vertexCount; i++ ) {
data->vertices[i].x -= vPos.X;
data->vertices[i].y -= vPos.Y;
data->vertices[i].x -= (*it)->GetPosition().X;
data->vertices[i].y -= (*it)->GetPosition().Y;
int tempX = data->vertices[i].x;
data->vertices[i].x = data->vertices[i].x * cos( fRotation ) - data->vertices[i].y * sin( fRotation );
data->vertices[i].y = data->vertices[i].y * cos( fRotation ) + tempX * sin( fRotation );
data->vertices[i].x += vPos.X;
data->vertices[i].y += vPos.Y;
}
}
}
}
}
{
for ( set<CForm *>::iterator it = sForms.begin(); it != sForms.end(); ++it ) {
for ( b2Shape *ShapeList = (*it)->GetBody()->GetShapeList(); ShapeList; ShapeList = ShapeList->GetNext() ) {
if( ShapeList->GetType() == e_polygonShape ) {
b2PolygonDef* data = (*it)->GetShape();
for( unsigned int i = 0; i < data->vertexCount; i++ ) {
data->vertices[i].x -= vPos.X;
data->vertices[i].y -= vPos.Y;
data->vertices[i].x -= (*it)->GetPosition().X;
data->vertices[i].y -= (*it)->GetPosition().Y;
int tempX = data->vertices[i].x;
data->vertices[i].x = data->vertices[i].x * cos( fRotation ) - data->vertices[i].y * sin( fRotation );
data->vertices[i].y = data->vertices[i].y * cos( fRotation ) + tempX * sin( fRotation );
data->vertices[i].x += vPos.X;
data->vertices[i].y += vPos.Y;
}
}
}
}
}
Is it possible that it does not work to change the vertices of the body while simulating?