本文整理汇总了C++中Stage::init方法的典型用法代码示例。如果您正苦于以下问题:C++ Stage::init方法的具体用法?C++ Stage::init怎么用?C++ Stage::init使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Stage
的用法示例。
在下文中一共展示了Stage::init方法的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);
}
示例2: create
Stage* Stage::create(Gamescene* _m) {
Stage *ret = new(std::nothrow) Stage();
if (ret && ret->init(_m)) {
ret->autorelease();
return ret;
}
else {
delete ret;
ret = nullptr;
return nullptr;
}
}