本文整理汇总了C++中core::array类的典型用法代码示例。如果您正苦于以下问题:C++ array类的具体用法?C++ array怎么用?C++ array使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了array类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setTexture
void CSoftwareRenderTarget::setTexture(const core::array<ITexture*>& texture, ITexture* depthStencil)
{
if (Texture != texture)
{
if (Texture[0])
Texture[0]->drop();
bool textureDetected = false;
for (u32 i = 0; i < texture.size(); ++i)
{
if (texture[i] && texture[i]->getDriverType() == EDT_SOFTWARE)
{
Texture[0] = texture[i];
Texture[0]->grab();
textureDetected = true;
break;
}
}
if (!textureDetected)
Texture[0] = 0;
}
}
示例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);
}
示例3: addUsableSlotArray
//! Adds the slots in the array to the usable slots
void CGUIIcon::addUsableSlotArray(const core::array<IGUIElement*>& slotArray)
{
s32 arraySize = slotArray.size();
for(s32 i = 0; i < arraySize; i++)
{
UsableSlots->push_back(slotArray[i]);
}
}
示例4: 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);
}
}
示例5: 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;
}
示例6: 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--;
}
}
示例7: v2s32
/*
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 ¤t_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;
}
示例8: create
void CFontTextTag::create( IExtendedText* text, const core::stringw& tag, const core::array<core::stringw>& params )
{
if ( params.size() == 0 )
{
text->setCurrentFont( text->getDefaultFont() );
}
else
{
core::map<core::stringw,IGUIFont*>::Node* node = FontMap.find( params[0] );
if ( node != NULL )
{
text->setCurrentFont( node->getValue() );
}
}
}
示例9: setFramesDirectionSet
void CSceneNodeAnimatorTexture::setFramesDirectionSet(
u32 direction_idx, const core::array<SAnimationFrame> &frames)
{
if (direction_idx >= m_DirectionSets.size())
for (u32 d = m_DirectionSets.size(); d <= direction_idx; d++)
m_DirectionSets.push_back(core::array<SAnimationFrame>());
u32 i=0;
for (i=0; i < m_DirectionSets[direction_idx].size(); ++i)
SAFE_DROP(m_DirectionSets[direction_idx][i].Texture);
m_DirectionSets[direction_idx].set_used(0);
for (i = 0; i < frames.size(); ++i)
{
m_DirectionSets[direction_idx].push_back(frames[i]);
SAFE_GRAB(frames[i].Texture);
}
}
示例10: Loop
//! constructor
CSceneNodeAnimatorTexture::CSceneNodeAnimatorTexture(const core::array<video::ITexture*>& textures,
s32 timePerFrame, bool loop, u32 now)
: Loop(loop), StartTime(now), TimePerFrame(timePerFrame)
{
#ifdef _DEBUG
setDebugName("CSceneNodeAnimatorTexture");
#endif
for (u32 i=0; i<textures.size(); ++i)
{
if (textures[i])
textures[i]->grab();
Textures.push_back(textures[i]);
}
EndTime = now + (timePerFrame * Textures.size());
}
示例11: 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);
}
}
示例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);
}
}
示例13: 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--;
}
}
示例14: getTextureName
std::string TextureSource::getTextureName(u32 id)
{
JMutexAutoLock lock(m_atlaspointer_cache_mutex);
if(id >= m_atlaspointer_cache.size())
{
errorstream<<"TextureSource::getTextureName(): id="<<id
<<" >= m_atlaspointer_cache.size()="
<<m_atlaspointer_cache.size()<<std::endl;
return "";
}
return m_atlaspointer_cache[id].name;
}
示例15: clear
void Mesh::clear()
{
flags = 0;
groupId = 0;
visgroupId = 0;
props = "";
color.clear();
position.set(0,0,0);
for(u32 s = 0; s < surfaces.size(); s++)
{
delete surfaces[s];
}
surfaces.clear();
}