本文整理汇总了C++中ObjectData::getRigidBody方法的典型用法代码示例。如果您正苦于以下问题:C++ ObjectData::getRigidBody方法的具体用法?C++ ObjectData::getRigidBody怎么用?C++ ObjectData::getRigidBody使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObjectData
的用法示例。
在下文中一共展示了ObjectData::getRigidBody方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: keyboard
void keyboard(unsigned char key, int x_pos, int y_pos)
{
btRigidBody* tempRB = objectsDataList.getRigidBody(3);
// Handle keyboard input
if(key == 27)//ESC
{
exit(0);
}
switch (key)
{
case 'a':
tempRB->applyForce(btVector3( 10, 0.f, 0.f ), btVector3(0.0f,0.0f,0.0f));
//Move cylinder X
break;
case 'd':
tempRB->applyForce(btVector3( -10, 0.f, 0.f ), btVector3(0.0f,0.0f,0.0f));
//Move cylinder -X
break;
case 'w':
tempRB->applyForce(btVector3( 0.0f, 0.f, 10.0f ), btVector3(0.0f,0.0f,0.0f));
//Move cylinder -Z
break;
case 's':
tempRB->applyForce(btVector3( 0.0, 0.f, -10.0f ), btVector3(0.0f,0.0f,0.0f));
//Move cylinder Z
break;
}
}
示例2: handleSpecialKeypress
void handleSpecialKeypress(int key, int x, int y)
{
btRigidBody* tempRB = objectsDataList.getRigidBody(2);
switch (key)
{
case GLUT_KEY_LEFT:
tempRB->applyCentralImpulse( btVector3( 2, 0.f, 0.f ) );
//Move circle X
break;
case GLUT_KEY_RIGHT:
tempRB->applyCentralImpulse( btVector3( -2, 0.f, 0.f ) );
//Move circle -X
break;
case GLUT_KEY_UP:
tempRB->applyCentralImpulse( btVector3( 0, 0.f, 2.f ) );
//Move circle -Z
break;
case GLUT_KEY_DOWN:
tempRB->applyCentralImpulse( btVector3( 0, 0.f, -2.f ) );
//Move circle Z
break;
}
}
示例3: resetGame
void resetGame()
{
float dt;
start = std::chrono::high_resolution_clock::now();
scoreOne = 1000;
cout << "globalObjCount" << globalObjCount << endl;
// reset items
for (int index = 0; index < globalObjCount; index++)
{
// if on the puck
if ( index != 0 )
{
btVector3 startPos;
if (objectsDataList.getRigidBody(index) && objectsDataList.getRigidBody(index)->getMotionState())
{
btTransform puckTrans;
puckTrans.setIdentity();
if ( index == 1 )
{
startPos = btVector3(-5.0f, -3.0f, -5.0f);
}
puckTrans.setOrigin(startPos);
btDefaultMotionState* puckMotionState = new btDefaultMotionState(puckTrans);
objectsDataList.getRigidBody(index)->setMotionState(puckMotionState);
objectsDataList.getRigidBody(index)->setLinearVelocity(btVector3(0.0f, 0.0f, 0.0f));
objectsDataList.getRigidBody(index)->setAngularVelocity(btVector3(0,0,0));
}
}
}
dt = getDT();
dynamicsWorld->stepSimulation(dt, 10.0f);
}
示例4: movePlayerOnePad
///////////////////////////////////////
// human interaction functions below //
// vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv///
void movePlayerOnePad (int x, int y)
{
btRigidBody* tempRB = objectsDataList.getRigidBody(1);
btVector3 tempVec3;
tempVec3 = tempRB->getLinearVelocity();
int xValue = 0;
int yValue = 0;
int zValue = 0;
int topFourth = h / 4;
int bottomFourth = topFourth * 3;
int leftFourth = w / 4;
int rightFourth = leftFourth * 3;
if ( x < leftFourth )
{
xValue += 5;
xValue = xValue + tempVec3.getX();
if(xValue > 15)
xValue = 15;
}
if ( x > rightFourth )
{
xValue -= 5;
xValue = xValue + tempVec3.getX();
if(xValue < -15)
xValue = -15;
}
if ( y < topFourth )
{
zValue += 5;
zValue = zValue + tempVec3.getZ();
if(zValue > 15)
zValue = 15;
}
if ( y > bottomFourth )
{
zValue -= 5;
zValue = zValue + tempVec3.getZ();
if(zValue < -15)
zValue = -15;
}
tempRB->setLinearVelocity(btVector3(xValue, yValue , zValue));
}
示例5: myMouse
void myMouse(int button, int state, int x, int y)
{
if(button == GLUT_LEFT_BUTTON && state == GLUT_DOWN)
{
cout << "Left Button Pressed" << endl;
btRigidBody* tempRB = objectsDataList.getRigidBody(1);
btVector3 tempVec3;
int xValue = 0;
int yValue = 0;
int zValue = 0;
int topFourth = h / 4;
int bottomFourth = topFourth * 3;
int leftFourth = w / 4;
int rightFourth = leftFourth * 3;
// move up
if ( y < topFourth )
{
zValue += 15;
}
// move down
if ( y > bottomFourth )
{
zValue -= 15;
}
// move left
if ( x < leftFourth )
{
xValue += 15;
}
// move rith
if ( x > rightFourth )
{
xValue -= 15;
}
tempVec3 = tempRB->getLinearVelocity();
tempRB->setLinearVelocity(btVector3(xValue + tempVec3.getX(), yValue + tempVec3.getY(), zValue + tempVec3.getZ()));
}
}