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


C++ Stage::add方法代码示例

本文整理汇总了C++中Stage::add方法的典型用法代码示例。如果您正苦于以下问题:C++ Stage::add方法的具体用法?C++ Stage::add怎么用?C++ Stage::add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Stage的用法示例。


在下文中一共展示了Stage::add方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: init

void init(void) {
	// create a 960x480 window with 60 framerate, no antialias and no fullscreen
	stage.init(960, 480, 60, 0, false);
	stage.setUpdateCallback(update); // internal loop callbacks this function every frame

	camera.initPerspective(80, 960.0f / 480.0f, 0.1f, 20.0f);
	camera.lookAt(glm::vec3(4, 4, 4), glm::vec3(0, 0, 0), glm::vec3(0, 1, 0));
	stage.add(&camera); // add a camera pointer to the scene

	sun.setDirection(-0.3f, -1.0f, 0.3f);
	sun.shadow = Shadows::PCF; // Percentage closer filtering shadows
	sun.ambient = 0.5f;
	sun.diffuse = 0.5f;
	sun.specular = 0.5f;
	stage.add(&sun);

	// init a 10x1x10 cube as a ground with a sand texture
	groundGeometry.init(10, 1, 10);
	groundMaterial.init("assets/sand_color.tga", "assets/sand_normal.tga");
	ground.init(&groundGeometry, &groundMaterial);
	ground.setPosition(0, -1, 0);
	stage.add(&ground);

	// init geometry as a 1x1x1 cube and init material as red color
	cubeGeometry.init(1, 1, 1);
	cubeMaterial.init(1, 0, 0);
	cube.init(&cubeGeometry, &cubeMaterial);
	stage.add(&cube);

	// load car model and texture
	carModel.init("assets/car.obj");
	carMaterial.init("assets/car.tga");

	// car model is too small for the scene so scale it by 10
	for (unsigned int i = 0; i < carModel.getChildCount(); ++i) {
		carModel.getGeometry(i).scale(10.0f);
	}
	
	// first four objects in the obj file are the wheels
	// last and the fifth object is the chassis
	carChassis.init(&carModel.getGeometry(4), &carMaterial);
	carChassis.setPosition(0, 0.25f, 2.5f);
	stage.add(&carChassis);
	for (int i = 0; i < 4; ++i) {
		carWheel[i].init(&carModel.getGeometry(i), &carMaterial);
		stage.add(&carWheel[i]);
	}

	// put the wheels in the right places
	glm::vec3 chassisPos = carChassis.getPosition();
	carWheel[0].setPosition(chassisPos.x + 0.5f, chassisPos.y - 0.25f, chassisPos.z - 1.0f);
	carWheel[1].setPosition(chassisPos.x - 0.5f, chassisPos.y - 0.25f, chassisPos.z - 1.0f);
	carWheel[2].setPosition(chassisPos.x + 0.5f, chassisPos.y - 0.25f, chassisPos.z + 1.0f);
	carWheel[3].setPosition(chassisPos.x - 0.5f, chassisPos.y - 0.25f, chassisPos.z + 1.0f);
}
开发者ID:jejatu,项目名称:3d,代码行数:55,代码来源:main.cpp

示例2: alive

GameManager::GameManager(char** av) : alive(true)
{ 
  fillArray();
  test2 = new sfSpriteSheet(skinArray[8].filePath, skinArray[8].anim, skinArray[8].frame);
  ships = new sfSpriteSheet("../Resources/Sprite/boss.gif", 1, 9);
  boom = new sfSpriteSheet(skinArray[7].filePath, skinArray[7].anim, skinArray[7].frame);
  boom2 = new sfSpriteSheet("../Resources/Sprite/boss_death.gif", 1, 9);

  this->input3 = new sfKeyboard();
  vaisseau2 = new GameComponent(test2, boom);
  this->net_ = new NetworkManager(av);
  
  input3->autoBind(UpKey, sf::Keyboard::W);
  input3->autoBind(DownKey, sf::Keyboard::S);
  input3->autoBind(LeftKey, sf::Keyboard::A);
  input3->autoBind(RightKey, sf::Keyboard::D);
  input3->autoBind(FireKey, sf::Keyboard::Space);
  
  Stage* st = new Stage();
  st->add(vaisseau2);
  this->stack_.push(st);
  
}
开发者ID:fiahil,项目名称:R-Type,代码行数:23,代码来源:GameManager.cpp


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