本文整理汇总了C++中ObjArray::push_back方法的典型用法代码示例。如果您正苦于以下问题:C++ ObjArray::push_back方法的具体用法?C++ ObjArray::push_back怎么用?C++ ObjArray::push_back使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObjArray
的用法示例。
在下文中一共展示了ObjArray::push_back方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
ObjArray *Chr::getWeapons(bool includeMagic) {
ObjArray *list = new ObjArray;
if (_weapon1)
list->push_back(_weapon1);
if (_weapon2)
list->push_back(_weapon2);
for (uint i = 0; i < _inventory.size(); i++)
switch (_inventory[i]->_type) {
case Obj::REGULAR_WEAPON:
case Obj::THROW_WEAPON:
list->push_back(_inventory[i]);
break;
case Obj::MAGICAL_OBJECT:
if (includeMagic)
list->push_back(_inventory[i]);
break;
default:
break;
}
return list;
}
示例2: main
int main(int argc, char **argv)
{
std::string filename;
if (argc == 2)
filename = argv[1];
else
filename = "image.bmp";
ObjArray objects;
////objects.push_back(new Sphere(vec3(0.0, 0, -20), 4, vec3(1.00, 0.32, 0.36), 1.0, 1.0));
//objects.push_back(new Sphere(vec3(0.0, 0, -20), 4, vec3(0, 0, 0), 1.0, 0.8));
//objects.push_back(new Sphere(vec3(5.0, -1, -15), 2, vec3(0.90, 0.76, 0.46), 1.0, 1));
//objects.push_back(new Sphere(vec3(5.0, 0, -25), 3, vec3(0.35, 0.97, 0.37), 1.0, 1));
//objects.push_back(new Sphere(vec3(-6, 0, -5), 3, vec3(0.9, 0.9, 0.9), 1.0, 1));
//objects.push_back(new Sphere(vec3(0, 5, -15), 1.0, vec3(0.2, 0.32, 0.9), 1.0, 1));
objects.push_back(new Sphere(vec3(-6, 4, 0), 4, vec3(0.7, 0.2, 0.2), 1.0, 0.8));
objects.push_back(new Sphere(vec3(6, 4, 0), 4, vec3(0.2, 0.7, 0.2), 1.0, 0.8));
objects.push_back(new Sphere(vec3(0, 4, 6), 4, vec3(0.2, 0.2, 0.7), 1.0, 0.8));
objects.push_back(new Disk(vec3(0, 0, 0), 40.0, glm::normalize(vec3(0, 1, 0)), vec3(0.2, 0.2, 0.25), 0.2, 1));
lights.push_back(vec3(10, 10, 10));
lights.push_back(vec3(-10, 10, 10));
render(objects, filename.c_str());
for (auto obj : objects)
{
delete obj;
}
return EXIT_SUCCESS;
}