当前位置: 首页>>代码示例>>C++>>正文


C++ Physics类代码示例

本文整理汇总了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());
}
开发者ID:audionerd,项目名称:FieldKit.cpp,代码行数:25,代码来源:FlockingParticlesApp.cpp

示例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
开发者ID:flair2005,项目名称:inVRs,代码行数:25,代码来源:ArticulatedPhysicsEntity.cpp

示例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);
	}
}
开发者ID:Bloodknight,项目名称:GMK,代码行数:25,代码来源:softBody.cpp

示例4: main

int main()
{
    Physics p;
    Achievements a;
    p.update();
    a.update();
    return 0;
}
开发者ID:Zephilinox,项目名称:DesignPatterns,代码行数:8,代码来源:main.cpp

示例5: main

int main() {
    Physics phys;
    int x = 0;
    while (true) {
        phys.run();
    }
    return 0;
}
开发者ID:bradenwatling,项目名称:Physics,代码行数:8,代码来源:main.cpp

示例6:

CursorSpringConnector::~CursorSpringConnector()
{
	Physics* physicsModule;
	physicsModule = (Physics*)SystemCore::getModuleByName("Physics");
	if (physicsModule) {
		physicsModule->removePhysicsObject(this);
		physicsModule->removeSimulationStepListener(this);
		physicsModule->removeSystemThreadListener(this);
	} // if
} // ~CursorSpringConnector
开发者ID:flair2005,项目名称:inVRs,代码行数:10,代码来源:CursorSpringConnector.cpp

示例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
开发者ID:flair2005,项目名称:inVRs,代码行数:10,代码来源:LinkedPhysicsEntity.cpp

示例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
开发者ID:flair2005,项目名称:inVRs,代码行数:11,代码来源:ArticulatedPhysicsEntity.cpp

示例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;

}
开发者ID:samtny,项目名称:pinball,代码行数:53,代码来源:PinballHost.cpp

示例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
  }
}
开发者ID:DomNomNom,项目名称:SuperFoxManCrate,代码行数:12,代码来源:enemy.cpp

示例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;
}
开发者ID:rxtsolar,项目名称:rtanimate,代码行数:12,代码来源:create.cpp

示例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.
}
开发者ID:DomNomNom,项目名称:SuperFoxManCrate,代码行数:12,代码来源:player.cpp

示例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.
}
开发者ID:DomNomNom,项目名称:SuperFoxManCrate,代码行数:13,代码来源:player.cpp

示例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;
}
开发者ID:maximbilan,项目名称:cpp_marmalade_sdk_the_pursuit_3d,代码行数:12,代码来源:game.cpp

示例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;

}
开发者ID:samtny,项目名称:pinball,代码行数:53,代码来源:PinballHost.cpp


注:本文中的Physics类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。