本文整理汇总了C++中Body::SetStatic方法的典型用法代码示例。如果您正苦于以下问题:C++ Body::SetStatic方法的具体用法?C++ Body::SetStatic怎么用?C++ Body::SetStatic使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Body
的用法示例。
在下文中一共展示了Body::SetStatic方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main( void )
{
glutInitDisplayMode( GLUT_RGBA | GLUT_DOUBLE );
glutInitWindowSize( 800, 600 );
glutCreateWindow( "PhyEngine" );
glutDisplayFunc( PhysicsLoop );
glutKeyboardFunc( Keyboard );
glutMouseFunc( Mouse );
glutIdleFunc( PhysicsLoop );
glMatrixMode( GL_PROJECTION );
glPushMatrix( );
glLoadIdentity( );
gluOrtho2D( 0, 80, 60, 0 );
glMatrixMode( GL_MODELVIEW );
glPushMatrix( );
glLoadIdentity( );
Circle c( 5.0f );
Body *b = scene.Add( &c, 40, 40 );
b->SetStatic( );
PolygonShape poly;
poly.SetBox( 30.0f, 1.0f );
b = scene.Add( &poly, 40, 55 );
b->SetStatic( );
b->SetOrient( 0 );
srand( 1 );
glutMainLoop( );
return 0;
}
示例2: OnInit
void BilliardsDemo::OnInit(GLFWwindow* window)
{
Scene::OnInit(window);
Model* model;
Body* body;
// Table
model = new Cube(glm::vec3(0, 0.7, 0));
glm::vec3 position = glm::vec3(0,1,0);
glm::vec3 scale = glm::vec3(10, 1, 25);
glm::quat orientation = glm::quat(1,0,0,0);
body = new Body(position, orientation, scale);
body->SetCollider(new BoxCollider(body, scale));
body->SetStatic();
objects.push_back(new Object(model, body));
model = new Cube(glm::vec3(0, 1, 0));
position = glm::vec3(-10, 1, 0);
scale = glm::vec3(1, 4, 25);
orientation = glm::quat(1, 0, 0, 0);
body = new Body(position, orientation, scale);
body->SetCollider(new BoxCollider(body, scale));
body->SetStatic();
objects.push_back(new Object(model, body));
model = new Cube(glm::vec3(0, 1, 0));
position = glm::vec3(10, 1, 0);
scale = glm::vec3(1, 4, 25);
orientation = glm::quat(1, 0, 0, 0);
body = new Body(position, orientation, scale);
body->SetCollider(new BoxCollider(body, scale));
body->SetStatic();
objects.push_back(new Object(model, body));
model = new Cube(glm::vec3(0, 1, 0));
position = glm::vec3(0, 1, -25);
scale = glm::vec3(10, 4, 1);
orientation = glm::quat(1, 0, 0, 0);
body = new Body(position, orientation, scale);
body->SetCollider(new BoxCollider(body, scale));
body->SetStatic();
objects.push_back(new Object(model, body));
model = new Cube(glm::vec3(0, 1, 0));
position = glm::vec3(0, 1, 25);
scale = glm::vec3(10, 4, 1);
orientation = glm::quat(1, 0, 0, 0);
body = new Body(position, orientation, scale);
body->SetCollider(new BoxCollider(body, scale));
body->SetStatic();
objects.push_back(new Object(model, body));
Reset();
}
示例3: LoadStaticScene
// Carga escena estaticas
void CGPEngineView::LoadStaticScene(int escena)
{
// inicializo el mundo
init = false;
_world.Clear();
Body *p;
gravity = Vector2 ( 0, 10.0f * gravityScale );
switch(escena)
{
case 0:
/*
// 2 triangulos de base y uno que cae
p = _world.AddTri(0, 5, 0, 0, 40, 5);
p->position = Vector2(0, 40);
p->SetStatic();
p = _world.AddTri(0, 5, 40,0 ,40, 5 );
p->position = Vector2(50, 40);
p->SetStatic();
p = _world.AddTri(10-5,10+5,10-5,10-5, 10+5,10+2*5);
p->position = Vector2(15.46 , 34.069);
p->velocity = Vector2(9.06 , 15.48);
p->SetOrient( -1.248819);
p->angularVelocity = -2.0813;
*/
p = _world.AddBox(48, 62, 100, 4);
p->SetStatic();
// base de la torre
p = _world.AddBox(85, 58, 30, 4);
p->SetStatic();
// torre inferior
p = _world.AddBox(75, 40, 2, 16);
break;
case 1:
// pendulo
{
Body *A = _world.AddCircle(40,2,1);
A->velocity = Vector2(5 , 0);
A->SetStatic();
p = _world.AddCircle(30,20,5);
p->velocity = Vector2(9.06 , 0);
p->restitution = 1;
_world.AddConstraint(p,A,25);
p = _world.AddCircle(50,20,5);
p->velocity = Vector2(-9.06 , 0);
p->restitution = 1;
_world.AddConstraint(p,A,25);
p = _world.AddCircle(40,20,5);
p->velocity = Vector2(-9.06 , 0);
p->restitution = 1;
_world.AddConstraint(p,A,25);
}
break;
case 2:
{
// cadena
int id = 0;
for(int j= 0;j<5;++j)
{
Body *A = _world.AddCircle(10+j*15,2,1);
A->SetStatic();
A->id = id++;
for(int i= 0;i<15;++i)
{
p = _world.AddCircle(35-i*2+j*15,10+i*2,1);
p->restitution = 1;
p->id = id++;
_world.AddConstraint(p,A,3);
A = p;
}
}
}
break;
case 3:
{
// triple pendulo
Body *A = _world.AddCircle(10,2,1);
A->SetStatic();
p = _world.AddCircle(9,3,1);
p->restitution = 1;
_world.AddConstraint(p,A,4);
A = p;
p = _world.AddCircle(10,9,1);
p->restitution = 1;
_world.AddConstraint(p,A,5);
//.........这里部分代码省略.........
示例4: OnChar
void CGPEngineView::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
int xPos = (mouse_x-ox)/ ex;
int yPos = (mouse_y-oy)/ ey;
switch(nChar)
{
case 32:
if(step_by_step)
{
_world.Update(fixed_dt);
}
break;
case 'c':
case 'C':
// Agregar circulo
{
Body *p = _world.AddCircle(xPos,yPos,Random(1,10));
p->velocity = Vector2(0, Random(1,15));
}
break;
case 'r':
case 'R':
// Agregar Rectangulo
{
Body *p = _world.AddBox(xPos,yPos,Random(1,10),Random(1,10));
p->velocity = Vector2(0, 5);
}
break;
case 'b':
case 'B':
// Agregar Ragg Dall Body
RagDollBody(xPos,yPos);
break;
case 't':
case 'T':
// Agregar Triangulo
{
float r = Random(1,10);
Body *p = _world.AddTri(-r,r,-r,-r, r,2*r);
p->position = Vector2(xPos, yPos);
p->velocity = Vector2(0, 5);
}
break;
case 'p':
case 'P':
{
// creo un piso
Body *floor = _world.AddBox(0,50,600,1);
floor->SetStatic();
}
break;
// escenas standard
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
LoadStaticScene(nChar-'0' - 1);
break;
case '0':
LoadStaticScene(9);
break;
}
CView::OnChar(nChar, nRepCnt, nFlags);
}