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


C++ array::push_back方法代码示例

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


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

示例1: initializeOccluders

void CCullingSystem::initializeOccluders()
{
	static core::array<SOccluderEntry> occluders_tmp;
	occluders_tmp.set_used(0);

	m_Occluders.sort();

	for (u32 i=0; i<m_Occluders.size(); i++)
	{
		bool occluded = false;

		for (u32 j=i+1; j<m_Occluders.size(); j++)
		{
			if (m_Occluders[j].isOccludeByPlanes(m_Occluders[i].tbbox))
			{
				occluded = true;
				break;
			}
		}

		if (!occluded)
		{
			occluders_tmp.push_back(m_Occluders[i]);	
		}
	}

	m_Occluders.set_used(0);
	m_Occluders = occluders_tmp;
}
开发者ID:zdementor,项目名称:my-base,代码行数:29,代码来源:CCullingSystem.cpp

示例2: makeFastFace

static void makeFastFace(TileSpec tile, u16 li0, u16 li1, u16 li2, u16 li3,
                         v3f p, v3s16 dir, v3f scale, u8 light_source, core::array<FastFace> &dest)
{
    FastFace face;

    // Position is at the center of the cube.
    v3f pos = p * BS;

    v3f vertex_pos[4];
    v3s16 vertex_dirs[4];
    getNodeVertexDirs(dir, vertex_dirs);
    for(u16 i=0; i<4; i++)
    {
        vertex_pos[i] = v3f(
                            BS/2*vertex_dirs[i].X,
                            BS/2*vertex_dirs[i].Y,
                            BS/2*vertex_dirs[i].Z
                        );
    }

    for(u16 i=0; i<4; i++)
    {
        vertex_pos[i].X *= scale.X;
        vertex_pos[i].Y *= scale.Y;
        vertex_pos[i].Z *= scale.Z;
        vertex_pos[i] += pos;
    }

    f32 abs_scale = 1.;
    if     (scale.X < 0.999 || scale.X > 1.001) abs_scale = scale.X;
    else if(scale.Y < 0.999 || scale.Y > 1.001) abs_scale = scale.Y;
    else if(scale.Z < 0.999 || scale.Z > 1.001) abs_scale = scale.Z;

    v3f normal(dir.X, dir.Y, dir.Z);

    u8 alpha = tile.alpha;

    float x0 = tile.texture.pos.X;
    float y0 = tile.texture.pos.Y;
    float w = tile.texture.size.X;
    float h = tile.texture.size.Y;

    face.vertices[0] = video::S3DVertex(vertex_pos[0], normal,
                                        MapBlock_LightColor(alpha, li0, light_source),
                                        core::vector2d<f32>(x0+w*abs_scale, y0+h));
    face.vertices[1] = video::S3DVertex(vertex_pos[1], normal,
                                        MapBlock_LightColor(alpha, li1, light_source),
                                        core::vector2d<f32>(x0, y0+h));
    face.vertices[2] = video::S3DVertex(vertex_pos[2], normal,
                                        MapBlock_LightColor(alpha, li2, light_source),
                                        core::vector2d<f32>(x0, y0));
    face.vertices[3] = video::S3DVertex(vertex_pos[3], normal,
                                        MapBlock_LightColor(alpha, li3, light_source),
                                        core::vector2d<f32>(x0+w*abs_scale, y0));

    face.tile = tile;

    dest.push_back(face);
}
开发者ID:jnumm,项目名称:minetest,代码行数:59,代码来源:mapblock_mesh.cpp

示例3: getBlocks

void MapSector::getBlocks(core::array<MapBlock*> &dest)
{
	core::map<s16, MapBlock*>::Iterator bi;

	bi = m_blocks.getIterator();
	for(; bi.atEnd() == false; bi++)
	{
		MapBlock *b = bi.getNode()->getValue();
		dest.push_back(b);
	}
}
开发者ID:DMV27,项目名称:minetest,代码行数:11,代码来源:mapsector.cpp

示例4: sizeof

bool CIrrDeviceWin32::activateJoysticks(core::array<SJoystickInfo> & joystickInfo)
{
#if defined _IRR_COMPILE_WITH_JOYSTICK_EVENTS_
	joystickInfo.clear();
	ActiveJoysticks.clear();

	const u32 numberOfJoysticks = ::joyGetNumDevs();
	JOYINFOEX info;
	info.dwSize = sizeof(info);
	info.dwFlags = JOY_RETURNALL;

	JoystickInfo activeJoystick;
	SJoystickInfo returnInfo;

	joystickInfo.reallocate(numberOfJoysticks);
	ActiveJoysticks.reallocate(numberOfJoysticks);

	u32 joystick = 0;
	for(; joystick < numberOfJoysticks; ++joystick)
	{
		if(JOYERR_NOERROR == joyGetPosEx(joystick, &info)
			&&
			JOYERR_NOERROR == joyGetDevCaps(joystick, 
											&activeJoystick.Caps,
											sizeof(activeJoystick.Caps)))
		{
			activeJoystick.Index = joystick;
			ActiveJoysticks.push_back(activeJoystick);

			returnInfo.Joystick = (u8)joystick;
			returnInfo.Axes = activeJoystick.Caps.wNumAxes;
			returnInfo.Buttons = activeJoystick.Caps.wNumButtons;
			returnInfo.Name = activeJoystick.Caps.szPname;
			returnInfo.PovHat = ((activeJoystick.Caps.wCaps & JOYCAPS_HASPOV) == JOYCAPS_HASPOV)
								? SJoystickInfo::POV_HAT_PRESENT : SJoystickInfo::POV_HAT_ABSENT;

			joystickInfo.push_back(returnInfo);
		}
	}

	for(joystick = 0; joystick < joystickInfo.size(); ++joystick)
	{
		char logString[256];
		(void)sprintf(logString, "Found joystick %d, %d axes, %d buttons '%s'",
			joystick, joystickInfo[joystick].Axes, 
			joystickInfo[joystick].Buttons, joystickInfo[joystick].Name.c_str());
		os::Printer::log(logString, ELL_INFORMATION);
	}

	return true;
#else
	return false;
#endif // _IRR_COMPILE_WITH_JOYSTICK_EVENTS_
}
开发者ID:jivibounty,项目名称:irrlicht,代码行数:54,代码来源:CIrrDeviceWin32.cpp

示例5: createBoxTower

// Create a tower of the specified number of boxes
void createBoxTower(IPhysxManager* physxManager, scene::ISceneManager* smgr, video::IVideoDriver* driver, core::array<SPhysxAndNodePair*>& objects, f32 towerSize, f32 density, const core::vector3df& position) {

    const core::vector3df scale(4,4,4);
    const f32 spacing = -2.0f*physxManager->getSkinWidth();
    core::vector3df pos = position + core::vector3df(0.0f, scale.Y/2.0f, 0.0f);

    while (towerSize > 0) {
        objects.push_back(createBox(physxManager, smgr, driver, pos, scale, density));
        pos.Y += (scale.Y + spacing);
        towerSize--;
    }

}
开发者ID:bdbdonp,项目名称:tubras,代码行数:14,代码来源:irrphysxFuncs.cpp

示例6: readIndices

//! read indices
void CIrrMeshFileLoader::readIndices(io::IXMLReader* reader, int indexCount, core::array<u16>& indices)
{
	indices.reallocate(indexCount);

	core::stringc data = reader->getNodeData();
	const c8* p = &data[0];

	for (int i=0; i<indexCount && *p; ++i)
	{
		findNextNoneWhiteSpace(&p);
		indices.push_back((u16)readInt(&p));
	}
}
开发者ID:jivibounty,项目名称:irrlicht,代码行数:14,代码来源:CIrrMeshFileLoader.cpp

示例7: load

	void Surface::load(BinaryFileReader* pReader)
	{
		flags = pReader->readLong();
		textureName = pReader->readString();

		lightMapId = pReader->readLong();
		pReader->readVec2f(&uvOffset);
		pReader->readVec2f(&uvScale);
		uvRotation = pReader->readFloat();
		s32 vtxCount = pReader->readLong();
		s32 triCount = pReader->readLong();
		s32 lineCount = pReader->readLong();

		for(s32 v = 0; v < vtxCount; v++)
		{
			Vertex *vtx = new Vertex();
			vtx->load(pReader);
			vertices.push_back(vtx);
		}

		for(s32 t = 0; t < triCount; t++)
		{
			Triangle tri;
			pReader->readBuffer(&tri, sizeof(tri));
			triangles.push_back(tri);
		}

		for(s32 l = 0; l < lineCount; l++)
		{
			Line line;
			pReader->readBuffer(&line,sizeof(line));
			lines.push_back(line);

		}

	}
开发者ID:jivibounty,项目名称:irrlicht,代码行数:36,代码来源:CCSMLoader.cpp

示例8: makeDrawSpecArrayFromString

/*
	Here is an example traditional set-up sequence for a DrawSpec list:

	std::string furnace_inv_id = "nodemetadata:0,1,2";
	core::array<GUIInventoryMenu::DrawSpec> draw_spec;
	draw_spec.push_back(GUIInventoryMenu::DrawSpec(
			"list", furnace_inv_id, "fuel",
			v2s32(2, 3), v2s32(1, 1)));
	draw_spec.push_back(GUIInventoryMenu::DrawSpec(
			"list", furnace_inv_id, "src",
			v2s32(2, 1), v2s32(1, 1)));
	draw_spec.push_back(GUIInventoryMenu::DrawSpec(
			"list", furnace_inv_id, "dst",
			v2s32(5, 1), v2s32(2, 2)));
	draw_spec.push_back(GUIInventoryMenu::DrawSpec(
			"list", "current_player", "main",
			v2s32(0, 5), v2s32(8, 4)));
	setDrawSpec(draw_spec);

	Here is the string for creating the same DrawSpec list (a single line,
	spread to multiple lines here):

	GUIInventoryMenu::makeDrawSpecArrayFromString(
			draw_spec,
			"nodemetadata:0,1,2",
			"invsize[8,9;]"
			"list[current_name;fuel;2,3;1,1;]"
			"list[current_name;src;2,1;1,1;]"
			"list[current_name;dst;5,1;2,2;]"
			"list[current_player;main;0,5;8,4;]");

	Returns inventory menu size defined by invsize[].
*/
v2s16 GUIInventoryMenu::makeDrawSpecArrayFromString(
		core::array<GUIInventoryMenu::DrawSpec> &draw_spec,
		const std::string &data,
		const std::string &current_name)
{
	v2s16 invsize(8,9);
	Strfnd f(data);
	while(f.atend() == false)
	{
		std::string type = trim(f.next("["));
		//infostream<<"type="<<type<<std::endl;
		if(type == "list")
		{
			std::string name = f.next(";");
			if(name == "current_name")
				name = current_name;
			std::string subname = f.next(";");
			s32 pos_x = stoi(f.next(","));
			s32 pos_y = stoi(f.next(";"));
			s32 geom_x = stoi(f.next(","));
			s32 geom_y = stoi(f.next(";"));
			infostream<<"list name="<<name<<", subname="<<subname
					<<", pos=("<<pos_x<<","<<pos_y<<")"
					<<", geom=("<<geom_x<<","<<geom_y<<")"
					<<std::endl;
			draw_spec.push_back(GUIInventoryMenu::DrawSpec(
					type, name, subname,
					v2s32(pos_x,pos_y),v2s32(geom_x,geom_y)));
			f.next("]");
		}
		else if(type == "invsize")
		{
			invsize.X = stoi(f.next(","));
			invsize.Y = stoi(f.next(";"));
			infostream<<"invsize ("<<invsize.X<<","<<invsize.Y<<")"<<std::endl;
			f.next("]");
		}
		else
		{
			// Ignore others
			std::string ts = f.next("]");
			infostream<<"Unknown DrawSpec: type="<<type<<", data=\""<<ts<<"\""
					<<std::endl;
		}
	}

	return invsize;
}
开发者ID:ray8888,项目名称:MINETEST-Minetest-classic-remoboray,代码行数:81,代码来源:guiInventoryMenu.cpp

示例9: getObjects

void MapBlockObjectList::getObjects(v3f origin, f32 max_d,
		core::array<DistanceSortedObject> &dest)
{
	for(core::map<s16, MapBlockObject*>::Iterator
			i = m_objects.getIterator();
			i.atEnd() == false; i++)
	{
		MapBlockObject *obj = i.getNode()->getValue();

		f32 d = (obj->getRelativeShowPos() - origin).getLength();

		if(d > max_d)
			continue;

		DistanceSortedObject dso(obj, d);

		dest.push_back(dso);
	}
}
开发者ID:DMV27,项目名称:minetest,代码行数:19,代码来源:mapblockobject.cpp

示例10: createMeshStack

// Create a stack of meshes, with the bottom row having the specified number of cubes
void createMeshStack(IPhysxManager* physxManager, scene::ISceneManager* smgr, video::IVideoDriver* driver, core::array<SPhysxAndNodePair*>& objects, scene::IMesh* mesh, f32 stackSize, f32 density) {

    const core::vector3df meshSize = mesh->getBoundingBox().getExtent();
    const f32 spacing = -2.0f*physxManager->getSkinWidth();
    core::vector3df pos(0.0f, meshSize.Y/2.0f, 0.0f);
    f32 offset = -stackSize * (meshSize.X + spacing) * 0.5f;

    while (stackSize > 0) {
        for (s32 i = 0 ; i < stackSize ; ++i) {
            pos.X = offset + (f32)i * (meshSize.X + spacing);
            objects.push_back(createMeshBoundingBox(physxManager, smgr, driver, mesh, pos, core::vector3df(1,1,1), density));
        }

        offset += meshSize.X / 2.0f;
        pos.Y += (meshSize.Y + spacing);
        stackSize--;
    }

}
开发者ID:bdbdonp,项目名称:tubras,代码行数:20,代码来源:irrphysxFuncs.cpp

示例11: createBoxStack

// Create a stack of boxes, with the bottom row having the specified number of boxes
void createBoxStack(IPhysxManager* physxManager, scene::ISceneManager* smgr, video::IVideoDriver* driver, core::array<SPhysxAndNodePair*>& objects, f32 stackSize, f32 density, const core::vector3df& position) {

    const core::vector3df scale(4,4,4);
    const f32 spacing = -2.0f*physxManager->getSkinWidth();
    core::vector3df pos = position + core::vector3df(0.0f, scale.Y/2.0f, 0.0f);
    f32 offset = -stackSize * (scale.X + spacing) * 0.5f;

    while (stackSize > 0) {
        for (s32 i = 0 ; i < stackSize ; ++i) {
            pos.X = offset + (f32)i * (scale.X + spacing);
            objects.push_back(createBox(physxManager, smgr, driver, pos, scale, density));
        }

        offset += scale.X / 2.0f;
        pos.Y += (scale.Y + spacing);
        stackSize--;
    }

}
开发者ID:bdbdonp,项目名称:tubras,代码行数:20,代码来源:irrphysxFuncs.cpp

示例12: getActiveObjects

void ClientEnvironment::getActiveObjects(v3f origin, f32 max_d,
		core::array<DistanceSortedActiveObject> &dest)
{
	for(core::map<u16, ClientActiveObject*>::Iterator
			i = m_active_objects.getIterator();
			i.atEnd()==false; i++)
	{
		ClientActiveObject* obj = i.getNode()->getValue();

		f32 d = (obj->getPosition() - origin).getLength();

		if(d > max_d)
			continue;

		DistanceSortedActiveObject dso(obj, d);

		dest.push_back(dso);
	}
}
开发者ID:MarkTraceur,项目名称:minetest-delta,代码行数:19,代码来源:environment.cpp

示例13: activateJoysticks

//! Activate any joysticks, and generate events for them.
bool CIrrDeviceSDL::activateJoysticks(core::array<SJoystickInfo> & joystickInfo)
{
#if defined(_IRR_COMPILE_WITH_JOYSTICK_EVENTS_)
	joystickInfo.clear();

	// we can name up to 256 different joysticks
	const int numJoysticks = core::min_(SDL_NumJoysticks(), 256);
	Joysticks.reallocate(numJoysticks);
	joystickInfo.reallocate(numJoysticks);

	int joystick = 0;
	for (; joystick<numJoysticks; ++joystick)
	{
		Joysticks.push_back(SDL_JoystickOpen(joystick));
		SJoystickInfo info;

		info.Joystick = joystick;
		info.Axes = SDL_JoystickNumAxes(Joysticks[joystick]);
		info.Buttons = SDL_JoystickNumButtons(Joysticks[joystick]);
		info.Name = SDL_JoystickName(joystick);
		info.PovHat = (SDL_JoystickNumHats(Joysticks[joystick]) > 0)
						? SJoystickInfo::POV_HAT_PRESENT : SJoystickInfo::POV_HAT_ABSENT;

		joystickInfo.push_back(info);
	}

	for(joystick = 0; joystick < (int)joystickInfo.size(); ++joystick)
	{
		char logString[256];
		(void)sprintf(logString, "Found joystick %d, %d axes, %d buttons '%s'",
		 joystick, joystickInfo[joystick].Axes,
   joystickInfo[joystick].Buttons, joystickInfo[joystick].Name.c_str());
		os::Printer::log(logString, ELL_INFORMATION);
	}

	return true;

#endif // _IRR_COMPILE_WITH_JOYSTICK_EVENTS_

	return false;
}
开发者ID:AwkwardDev,项目名称:pseuwow,代码行数:42,代码来源:CIrrDeviceSDL.cpp

示例14: getTextureIdDirect


//.........这里部分代码省略.........
	
	video::IVideoDriver* driver = m_device->getVideoDriver();
	assert(driver);

	video::ITexture *t = NULL;

	/*
		An image will be built from files and then converted into a texture.
	*/
	video::IImage *baseimg = NULL;
	
	// If a base image was found, copy it to baseimg
	if(base_image_id != 0)
	{
		JMutexAutoLock lock(m_atlaspointer_cache_mutex);

		SourceAtlasPointer ap = m_atlaspointer_cache[base_image_id];

		video::IImage *image = ap.atlas_img;
		
		if(image == NULL)
		{
			infostream<<"getTextureIdDirect(): WARNING: NULL image in "
					<<"cache: \""<<base_image_name<<"\""
					<<std::endl;
		}
		else
		{
			core::dimension2d<u32> dim = ap.intsize;

			baseimg = driver->createImage(video::ECF_A8R8G8B8, dim);

			core::position2d<s32> pos_to(0,0);
			core::position2d<s32> pos_from = ap.intpos;
			
			image->copyTo(
					baseimg, // target
					v2s32(0,0), // position in target
					core::rect<s32>(pos_from, dim) // from
			);

			/*infostream<<"getTextureIdDirect(): Loaded \""
					<<base_image_name<<"\" from image cache"
					<<std::endl;*/
		}
	}
	
	/*
		Parse out the last part of the name of the image and act
		according to it
	*/

	std::string last_part_of_name = name.substr(last_separator_position+1);
	//infostream<<"last_part_of_name=\""<<last_part_of_name<<"\""<<std::endl;

	// Generate image according to part of name
	if(!generate_image(last_part_of_name, baseimg, m_device, &m_sourcecache))
	{
		errorstream<<"getTextureIdDirect(): "
				"failed to generate \""<<last_part_of_name<<"\""
				<<std::endl;
	}

	// If no resulting image, print a warning
	if(baseimg == NULL)
	{
		errorstream<<"getTextureIdDirect(): baseimg is NULL (attempted to"
				" create texture \""<<name<<"\""<<std::endl;
	}
	
	if(baseimg != NULL)
	{
		// Create texture from resulting image
		t = driver->addTexture(name.c_str(), baseimg);
	}
	
	/*
		Add texture to caches (add NULL textures too)
	*/

	JMutexAutoLock lock(m_atlaspointer_cache_mutex);
	
	u32 id = m_atlaspointer_cache.size();
	AtlasPointer ap(id);
	ap.atlas = t;
	ap.pos = v2f(0,0);
	ap.size = v2f(1,1);
	ap.tiled = 0;
	core::dimension2d<u32> baseimg_dim(0,0);
	if(baseimg)
		baseimg_dim = baseimg->getDimension();
	SourceAtlasPointer nap(name, ap, baseimg, v2s32(0,0), baseimg_dim);
	m_atlaspointer_cache.push_back(nap);
	m_name_to_id.insert(name, id);

	/*infostream<<"getTextureIdDirect(): "
			<<"Returning id="<<id<<" for name \""<<name<<"\""<<std::endl;*/
	
	return id;
}
开发者ID:fusionlightcat,项目名称:minetest,代码行数:101,代码来源:tile.cpp

示例15: writeOutXMLDescription

void CCombatNPC::writeOutXMLDescription(core::array<core::stringw>& names, core::array<core::stringw>& values) const {
    
	IAIEntity::writeOutXMLDescription(names, values);
  
	core::stringw strw;
	names.push_back(core::stringw(L"waypointGroupName"));
	values.push_back(core::stringw(WaypointGroup->getName()).c_str());
	names.push_back(core::stringw(L"startWaypointID"));
	strw = (CurrentWaypoint ? core::stringw(CurrentWaypoint->getID()) : core::stringw(0));
	values.push_back(strw);
	names.push_back(core::stringw(L"fovDimensions"));
	core::vector3df dim = (FieldOfView ? FieldOfView->getDimensions() : core::vector3df(0,0,0));
	strw = core::stringw(dim.X);
	strw += ",";
	strw += dim.Y;
	strw += ",";
	strw += dim.Z;
	values.push_back(strw);
	names.push_back(core::stringw(L"range"));
	strw = core::stringw(Range);    
	values.push_back(strw);
	names.push_back(core::stringw(L"moveSpeed"));
	strw = core::stringw(MoveSpeed);
	values.push_back(strw);
	names.push_back(core::stringw(L"atDestinationThreshold"));
	strw = core::stringw(AtDestinationThreshold);
	values.push_back(strw);
	names.push_back(core::stringw(L"fovOcclusionCheck"));
	strw = core::stringw(FovOcclusionCheck);
	values.push_back(strw);
	names.push_back(core::stringw(L"checkFovForEnemies"));
	strw = core::stringw(CheckFovForEnemies);
	values.push_back(strw);
	names.push_back(core::stringw(L"checkFovForAllies"));
	strw = core::stringw(CheckFovForAllies);
	values.push_back(strw);
         
}
开发者ID:Assyr,项目名称:PlasmaDefence,代码行数:38,代码来源:CCombatNPC.cpp


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