本文整理汇总了C++中ShapeList::size方法的典型用法代码示例。如果您正苦于以下问题:C++ ShapeList::size方法的具体用法?C++ ShapeList::size怎么用?C++ ShapeList::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ShapeList
的用法示例。
在下文中一共展示了ShapeList::size方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RefteshTotalData
void shapeGroup::RefteshTotalData()
{
ShapeList TMPShapeList = SG_ShapeData;
ShapeList::iterator SG_ShapeData_Iterator = TMPShapeList.begin();
SG_Size = TMPShapeList.size();
const int VAOSize = SG_Size * 12;
const int ItemSize = SG_Size * 20;
GLfloat* SG_TmpTotalData = (GLfloat*)malloc(sizeof(GLfloat) * ItemSize);
if (SG_TmpTotalData == nullptr)
{
std::cout << "[Warning]Can't malloc(" << sizeof(GLfloat) * ItemSize << ")" << std::endl;
return;
}
//start to copy
for (int LoopShapeNumber = 0; LoopShapeNumber < SG_Size; LoopShapeNumber++)
{
//VAO
SG_TmpTotalData[LoopShapeNumber * 12 + 0] = SG_ShapeData_Iterator->Shape->VAO_Data[0] + SG_ShapeData_Iterator->Location[0];
SG_TmpTotalData[LoopShapeNumber * 12 + 1] = SG_ShapeData_Iterator->Shape->VAO_Data[1] + SG_ShapeData_Iterator->Location[1];
SG_TmpTotalData[LoopShapeNumber * 12 + 2] = SG_ShapeData_Iterator->Shape->VAO_Data[2] + SG_ShapeData_Iterator->Location[2];
SG_TmpTotalData[LoopShapeNumber * 12 + 3] = SG_ShapeData_Iterator->Shape->VAO_Data[3] + SG_ShapeData_Iterator->Location[0];
SG_TmpTotalData[LoopShapeNumber * 12 + 4] = SG_ShapeData_Iterator->Shape->VAO_Data[4] + SG_ShapeData_Iterator->Location[1];
SG_TmpTotalData[LoopShapeNumber * 12 + 5] = SG_ShapeData_Iterator->Shape->VAO_Data[5] + SG_ShapeData_Iterator->Location[2];
SG_TmpTotalData[LoopShapeNumber * 12 + 6] = SG_ShapeData_Iterator->Shape->VAO_Data[6] + SG_ShapeData_Iterator->Location[0];
SG_TmpTotalData[LoopShapeNumber * 12 + 7] = SG_ShapeData_Iterator->Shape->VAO_Data[7] + SG_ShapeData_Iterator->Location[1];
SG_TmpTotalData[LoopShapeNumber * 12 + 8] = SG_ShapeData_Iterator->Shape->VAO_Data[8] + SG_ShapeData_Iterator->Location[2];
SG_TmpTotalData[LoopShapeNumber * 12 + 9] = SG_ShapeData_Iterator->Shape->VAO_Data[9] + SG_ShapeData_Iterator->Location[0];
SG_TmpTotalData[LoopShapeNumber * 12 + 10] = SG_ShapeData_Iterator->Shape->VAO_Data[10] + SG_ShapeData_Iterator->Location[1];
SG_TmpTotalData[LoopShapeNumber * 12 + 11] = SG_ShapeData_Iterator->Shape->VAO_Data[11] + SG_ShapeData_Iterator->Location[2];
//TexturePos
for (int i = 0; i < 8; i++)
{
SG_TmpTotalData[VAOSize + LoopShapeNumber * 8 + i] = SG_ShapeData_Iterator->Shape->TexturePos_Data[i];
}
SG_ShapeData_Iterator++;
}
SG_TotalData = SG_TmpTotalData;
SG_NeedRefreshBuffer = true;
SG_IsRefreshingData = false;
}
示例2: OnDropTable
void DatabaseCanvas::OnDropTable(wxCommandEvent &event)
{
ShapeList list;
bool isTable;
int answer;
MyErdTable *erdTable = NULL;
DatabaseTable *table = NULL;
wxString name;
ConstraintSign *sign = NULL;
Constraint *constraint = NULL;
DrawingDocument *doc = (DrawingDocument *) m_view->GetDocument();
Database *db = doc->GetDatabase();
std::vector<std::wstring> errors, localColumns, refColumn;
std::vector<FKField *> newFK;
std::wstring command;
int match = 0;
GetSelectedShapes( list );
if( list.size() == 1 )
isTable = true;
else
isTable = false;
for( ShapeList::iterator it = list.begin(); it != list.end(); it++ )
{
MyErdTable *tbl = wxDynamicCast( (*it), MyErdTable );
if( tbl )
erdTable = tbl;
ConstraintSign *s = wxDynamicCast( (*it), ConstraintSign );
if( s )
sign = s;
}
if( isTable )
{
table = &( const_cast<DatabaseTable &>( erdTable->GetTable() ) );
name = const_cast<DatabaseTable &>( erdTable->GetTable() ).GetTableName();
}
else
{
constraint = sign->GetConstraint();
constraint->GetLocalColumns( localColumns );
constraint->GetRefColumns( refColumn );
match = constraint->GetPGMatch();
}
int eventId = event.GetId();
if( eventId == wxID_DROPOBJECT )
{
wxString message = _( "You are about to delete " );
if( isTable )
message += _( "table " ) + name + _( ". Are you sure?" );
else
{
message += _( "foreign key " );
wxString fkName = constraint->GetName();
if( !fkName.empty() )
message += fkName;
else
message += _( " on " ) + const_cast<DatabaseTable *>( constraint->GetFKTable() )->GetTableName() + _( " references " ) + constraint->GetRefTable() + _( ". Are you sure?" );
}
answer = wxMessageBox( message, _( "Database" ), wxYES_NO | wxNO_DEFAULT );
}
else
answer = wxYES;
if( answer == wxYES )
{
if( isTable && ( ( eventId == wxID_DROPOBJECT && !db->DeleteTable( name.ToStdWstring(), errors ) ) || eventId != wxID_DROPOBJECT ) )
{
if( m_realSelectedShape == m_selectedShape )
{
m_realSelectedShape = NULL;
ShapeList listShapes;
m_pManager.GetShapes( CLASSINFO( MyErdTable ), listShapes );
int size = listShapes.size();
if( listShapes.size() == 1 )
m_realSelectedShape = NULL;
else
{
MyErdTable *tableToRemove = (MyErdTable *) ( listShapes.Item( size - 1 )->GetData() );
if( tableToRemove == erdTable )
m_realSelectedShape = (MyErdTable *) ( listShapes.Item( size - 2 )->GetData() );
else
{
bool found = false;
int i;
for( i = 0; i < size - 1 || !found; i++ )
if( listShapes.Item( i )->GetData() == erdTable )
found = true;
m_realSelectedShape = listShapes.Item( i + 1 )->GetData();
}
}
}
m_pManager.RemoveShape( erdTable );
/* for( ShapeList::iterator it = listShapes.begin(); it != listShapes.end() || !nextShapeFound; ++it )
{
CommentFieldShape *shape = wxDynamicCast( (*it), CommentFieldShape );
if( m_showComments )
{
shape->SetText( const_cast<Field *>( shape->GetFieldForComment() )->GetComment() );
}
else
{
shape->SetText( wxEmptyString );
//.........这里部分代码省略.........
示例3: sceneBoundary
DemoScene raytracer::gui::constructDemoScene()
{
/// Load resources
ResourceManager* resourceManager = ResourceManager::getInstance();
Texture* terrainTexture = new TerrainHeightTexture( // multitexture for terrain
resourceManager->createImage("terrainImage1", "resources/terrain_dirt.tga"),
resourceManager->createImage("terrainImage2", "resources/terrain_grass.tga"),
resourceManager->createImage("terrainImage3", "resources/terrain_rock.tga"),
resourceManager->createImage("terrainImage4", "resources/terrain_snow.tga")
);
std::vector<Image*> skyBoxImages(6);
skyBoxImages[0] = resourceManager->createImage("skyboxFront", "resources/miramar_ft.tga");
skyBoxImages[1] = resourceManager->createImage("skyboxRight", "resources/miramar_rt.tga");
skyBoxImages[2] = resourceManager->createImage("skyboxBack", "resources/miramar_bk.tga");
skyBoxImages[3] = resourceManager->createImage("skyboxLeft", "resources/miramar_lf.tga");
skyBoxImages[4] = resourceManager->createImage("skyboxUp", "resources/miramar_up.tga");
skyBoxImages[5] = resourceManager->createImage("skyboxDown", "resources/miramar_dn.tga");
std::vector<Texture*> skyBoxTextures(6);
skyBoxTextures[0] = resourceManager->createTexture("skyboxFrontTexture", "skyboxFront");
skyBoxTextures[1] = resourceManager->createTexture("skyboxRightTexture", "skyboxRight");
skyBoxTextures[2] = resourceManager->createTexture("skyboxBackTexture", "skyboxBack");
skyBoxTextures[3] = resourceManager->createTexture("skyboxLeftTexture", "skyboxLeft");
skyBoxTextures[4] = resourceManager->createTexture("skyboxUpTexture", "skyboxUp");
skyBoxTextures[5] = resourceManager->createTexture("skyboxDownTexture", "skyboxDown");
// Define scene
AABB sceneBoundary(Vector3(-1000, -1000, -1000), Vector3(1000, 1000, 1000));
ShapeList shapes;
shapes.push_back(new Sphere(Vector3(0.0f, 8.0f, -25.0f), 2.0f,
new Material(0.5f, 1.2f, 0.5f, 20.0f, Material::NO_REFLECTION,
Material::NO_REFRACTION, Colour(0.4f, 0.4f, 0.8f), NULL)
));
shapes.push_back(new Sphere(Vector3(-4.0f, 10.0f, -20.0f), 2.0f,
new Material(0.5f, 3.0f, 1.0f, 20.0f, 1.0f,
Material::NO_REFRACTION, Colour(), NULL)
));
shapes.push_back(new Sphere(Vector3(0.0f, 5.0f, -15.0f), 2.0f,
new Material(0.5f, 1.2f, 0.5f, 20.0f, 0.5f,
1.6666, Colour(0.8f, 0.2f, 0.2f), NULL)
));
shapes.push_back(new Sphere(Vector3(3.0f, 5.0f, -26.5f), 1.0f,
new Material(5.0f, 0.0f, 0.0f, 0.0f, 0.4f,
Material::NO_REFRACTION, Colour(0.9f, 0.65f, 0.0f), NULL)
));
// Load skybox
shapes.push_back(shapeloaders::getSkyBox(common::SKYBOX_SIZE, skyBoxTextures));
// Define all possible viewpoints
std::vector<Camera> cameras;
cameras.reserve(3);
cameras.push_back(Camera(
Vector3(0, 5.0f, 0), Vector3(0, 0, -1), Vector3(0, 1, 0),
Rect(-100, 100, -100, 100), 200, false));
cameras.push_back(Camera(
Vector3(-10, 3.0f, -10.0f), Vector3(1, 0.2f, -1), Vector3(0, 1, 0),
Rect(-100, 100, -100, 100), 200, false));
cameras.push_back(Camera(
Vector3(5.0f, 30.0f, -50.0f), Vector3(0.0f, -0.6f, 1), Vector3(0, 1, 0),
Rect(-100, 100, -100, 100), 200, false));
// Load all possible terrain
std::vector<std::string> heightmapFilenames;
heightmapFilenames.push_back("resources/heightmap.tga");
heightmapFilenames.push_back("resources/heightmap2.tga");
heightmapFilenames.push_back("resources/heightmap3.tga");
std::vector<Image*> heightmaps;
for (unsigned int i = 0; (i < heightmapFilenames.size()); i++)
heightmaps.push_back( resourceManager->createImage("heightmap", heightmapFilenames[i]) );
std::vector<Vector3> terrainOffsets;
for (unsigned int i = 0; (i < heightmaps.size()); i++)
{
terrainOffsets.push_back(Vector3(
-((common::TERRAIN_CELL_SIZE * heightmaps[i]->getWidth()) / 2.0f),
0.0f, -((common::TERRAIN_CELL_SIZE * heightmaps[i]->getHeight()) / 2.0f))
);
}
ShapeList terrainVariants;
for (unsigned int i = 0; (i < heightmaps.size()); i++)
{
Shape* unoptimisedTerrain = shapeloaders::getTerrainFromHeightmap(
heightmapFilenames[i], common::TERRAIN_CELL_SIZE,
common::TERRAIN_MAX_HEIGHT, terrainOffsets[i], terrainTexture, false);
Shape* optimisedTerrain = shapeloaders::getTerrainFromHeightmap(
heightmapFilenames[i], common::TERRAIN_CELL_SIZE,
common::TERRAIN_MAX_HEIGHT, terrainOffsets[i], terrainTexture, true);
terrainVariants.push_back(unoptimisedTerrain);
terrainVariants.push_back(optimisedTerrain);
}
// Construct test shapes (lines of each terrain's octree)
ShapeList octreeLines;
for (unsigned int i = 0; (i < terrainVariants.size()); i += 2) // go in 2s so unoptimised terrain is skipped
{
LineList lines = dynamic_cast<Octree*>(terrainVariants[i + 1])->getBoundingLines();
ShapeList lineShapes = generateLines(lines, 0.4f, NULL);
BoundingShape* rootOfLines = new BoundingShape(lineShapes, sceneBoundary);
octreeLines.push_back(rootOfLines);
}
// Create renderer to render scene
Raytracer* renderer = new Raytracer(cameras[0]);
//.........这里部分代码省略.........