本文整理汇总了C++中Physics类的典型用法代码示例。如果您正苦于以下问题:C++ Physics类的具体用法?C++ Physics怎么用?C++ Physics使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Physics类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: printf
void FlockingParticlesApp::testParticleCreation() {
printf("running testParticleCreation\n");
timer->stop();
timer->start();
BasicSpace* space = new BasicSpace(Vec3f::zero(), Vec3f(getWindowWidth(), getWindowHeight(), 0));
Physics* physics = new Physics(space);
Emitter* emitter = new Emitter(physics);
physics->emitter = emitter;
emitter->setPosition(space->getCenter());
emitter->setInterval(0.0001);
emitter->setRate(50000);
emitter->setMax(50 * 1000);
int numIterations = 10;
for(int i=0; i<numIterations; i++) {
physics->update(0.016f);
//physics->createParticle();
}
timer->stop();
printf("%f s \n", timer->getSeconds());
}
示例2:
ArticulatedPhysicsEntity::~ArticulatedPhysicsEntity()
{
SimplePhysicsEntity* entity;
unsigned entityId;
unsigned rigidBodyIndex, entityIndex;
std::map<unsigned, unsigned>::iterator it;
Physics* physics = (Physics*)SystemCore::getModuleByName("Physics");
if (physics && articulatedBody->isAddedToSimulation())
physics->removePhysicsObject(this);
// Clear rigidBody-Pointer in SimplePhysicsEntity
for (it = rigidBodyMapping.begin(); it != rigidBodyMapping.end(); ++it)
{
rigidBodyIndex = (*it).first;
entityIndex = (*it).second;
entityId = this->environmentBasedId + entityIndex;
entity = (SimplePhysicsEntity*)WorldDatabase::getEntityWithEnvironmentId(entityId);
if (entity)
entity->rigidBody = NULL;
} // for
delete articulatedBody;
} // ~ArticulatedPhysicsEntity
示例3: createPhysShape
void SoftBody::createPhysShape()
{
Physics* physics = Physics::getPhysics(isServerObject());
if (physics)
{
createUniqVertexList();
PhysSoftInfo physDescr;
physDescr.shapeType = PhysInfo::ST_SOFTMESH;
physDescr.physPolyList = mPhysPolyList;
physDescr.owner = this;
physDescr.mass = mDataBlock->mass;
physDescr.poseMatchKoef = mDataBlock->poseMatchKoef;
for(U8 i=0;i<mDataBlock->attachedPointsNum;i++)
{
physDescr.attachPoints.push_back(mDataBlock->attachedPoints[i]);
}
mPhysShape = physics->createPhysShapeSoft(physDescr);
mPhysShape->setTransform(mObjToWorld);
}
}
示例4: main
int main()
{
Physics p;
Achievements a;
p.update();
a.update();
return 0;
}
示例5: main
int main() {
Physics phys;
int x = 0;
while (true) {
phys.run();
}
return 0;
}
示例6:
CursorSpringConnector::~CursorSpringConnector()
{
Physics* physicsModule;
physicsModule = (Physics*)SystemCore::getModuleByName("Physics");
if (physicsModule) {
physicsModule->removePhysicsObject(this);
physicsModule->removeSimulationStepListener(this);
physicsModule->removeSystemThreadListener(this);
} // if
} // ~CursorSpringConnector
示例7: initializeJoints
void LinkedPhysicsEntity::setEnvironment(Environment* env) {
Entity::setEnvironment(env);
if (!addedToSimulation) {
initializeJoints();
Physics* physicsModule = (Physics*)SystemCore::getModuleByName("Physics");
assert(physicsModule);
physicsModule->addPhysicsObject(this);
addedToSimulation = true;
} // if
} // setEnvironment
示例8: assert
void ArticulatedPhysicsEntity::setEnvironment(Environment* env)
{
Entity::setEnvironment(env);
if (articulatedBody && !addedToSimulation)
{
Physics* physicsModule = (Physics*)SystemCore::getModuleByName("Physics");
assert(physicsModule);
physicsModule->addPhysicsObject(this);
addedToSimulation = true;
} // if
} // setEnvironment
示例9: PinballBridgeInterface
void PinballHost::init(const char *gameName) {
std::cout << "starting " << gameName << std::endl;
PinballBridgeInterface *bi = new PinballBridgeInterface();
bi->setGameName(gameName);
Playfield *f = new Playfield();
f->setBridgeInterface(bi);
f->init();
Physics *p = new Physics();
p->setBridgeInterface(bi);
p->setPlayfield(f);
p->init();
Camera *c = new Camera();
c->setBridgeInterface(bi);
c->setPlayfield(f);
c->init();
Editor *t = new Editor();
t->setBridgeInterface(bi);
t->setPlayfield(f);
t->setCamera(c);
t->setPhysics(p);
t->init();
GlutEngine *e = new GlutEngine();
e->init();
Renderer *r = new Renderer();
r->setBridgeInterface(bi);
r->setPlayfield(f);
r->setPhysics(p);
r->setCamera(c);
r->setEditor(t);
r->init();
Game *g = new Game();
g->setBridgeInterface(bi);
g->setPhysics(p);
g->setRenderer(r);
g->init();
// TODO: find factoring error/s
e->setPhysics(p);
e->setRenderer(r);
e->setGame(g);
e->setEditor(t);
_engine = e;
}
示例10: canGoY
void Enemy::canGoY(float dt, const Physics &phys) {
pos.y += vel.y * dt;
for (float changeY = phys.testY(*this); changeY!=0; changeY = phys.testY(*this)) {
pos.y += phys.testY(*this);
if (phys.gravAngle%180 == 0) vel.setY(0, phys.gravAngle);
else hitWall = true;
}
if (phys.testBoundsY(*this) != 0) { // when fallen into the pit
anger(phys);
dead = true; // indicate death to reset
}
}
示例11: main
int main(int argc, char** argv)
{
Physics physics;
if (argc != 3 && argc != 2) {
cerr << "usage: " << argv[0] <<
" <scene.sce> [output_suffix]" << endl;
return 1;
}
physics.parse(argv[1]);
physics.write(argv[2] ? argv[2] : "scene");
return 0;
}
示例12: canGoY
void Player::canGoY(float dt, const Physics &phys) {
pos.y += vel.y * dt;
for (float changeY = phys.testY(*this); changeY!=0; changeY = phys.testY(*this)) {
pos.y += changeY;
vel.y = 0;
if ( // if there was a collision with the ground
( (changeY < 0 && phys.gravAngle==0*90) || (changeY>0 && phys.gravAngle==2*90) )
&& abs(changeY)<=abs(phys.testX(*this))
) inAir = false;
}
if (phys.testBoundsY(*this) != 0) dead = true; // player fell into a pit.
}
示例13: canGoX
// === private functions: ===
void Player::canGoX(float dt, const Physics &phys) {
pos.x += vel.x * dt;
for (float changeX = phys.testX(*this); changeX!=0; changeX = phys.testX(*this)) { // as long as there are collisions, keep checking
pos.x += changeX;
vel.x = 0;
if ( // if there was a collision with the ground
( (changeX < 0 && phys.gravAngle==1*90) || (changeX>0 && phys.gravAngle==3*90) )
&& abs(changeX)<=abs(phys.testY(*this))
) inAir = false;
}
if (phys.testBoundsX(*this) != 0) dead = true; // player fell into a pit.
}
示例14: CreateGameLevel
GameLevel* Game::CreateGameLevel( const int modeID, const int levelID )
{
Physics* physics = Physics::GetInstance();
physics->Init();
GameLevel* gameLevel = new GameLevel( modeID, levelID );
gameLevel->Init();
physics->FreeInstance();
return gameLevel;
}
示例15: PinballBridgeInterface
void PinballHost::init() {
PinballBridgeInterface *bi = new PinballBridgeInterface();
bi->setGameName("Flipperfall");
bi->init();
Playfield *f = new Playfield();
f->setBridgeInterface(bi);
f->init();
Physics *p = new Physics();
p->setBridgeInterface(bi);
p->setPlayfield(f);
p->init();
Camera *c = new Camera();
c->setBridgeInterface(bi);
c->setPlayfield(f);
c->init();
Editor *t = new Editor();
t->setBridgeInterface(bi);
t->setPlayfield(f);
t->setCamera(c);
t->setPhysics(p);
t->init();
GlutEngine *e = new GlutEngine();
e->init();
Renderer *r = new Renderer();
r->setBridgeInterface(bi);
r->setPlayfield(f);
r->setPhysics(p);
r->setCamera(c);
r->setEditor(t);
r->init();
Game *g = new Game();
g->setBridgeInterface(bi);
g->setPhysics(p);
g->setRenderer(r);
g->init();
// TODO: find factoring error/s
e->setPhysics(p);
e->setRenderer(r);
e->setGame(g);
e->setEditor(t);
_glutEngine = e;
}