本文整理汇总了C++中Vertices::size方法的典型用法代码示例。如果您正苦于以下问题:C++ Vertices::size方法的具体用法?C++ Vertices::size怎么用?C++ Vertices::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vertices
的用法示例。
在下文中一共展示了Vertices::size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setTexCoords
void Model::setTexCoords(const Vertices& texCoords)
{
m_texCoords.resize(texCoords.size());
std::memcpy(m_texCoords.data(), texCoords.data(), texCoords.size() * 2 * sizeof(float));
if (m_texCoordsVBO)
{
m_texCoordsVBO.bind();
m_texCoordsVBO.write(texCoords);
m_texCoordsVBO.release();
}
}
示例2: InitVertices
void InitVertices( Vertices& vertices, Indices& indices )
{
assert( 0 == vertices.size() );
assert( 0 == indices.size() );
const float edgeSize = 100.0f;
const unsigned nVerticesPerEdge = 201;
for( unsigned i=0; i<nVerticesPerEdge; ++i )
{
for( unsigned j=0; j<nVerticesPerEdge; ++j )
{
vertices.push_back(
Vertex( 0.0f, edgeSize*i/(nVerticesPerEdge-1) - edgeSize/2, edgeSize*j/(nVerticesPerEdge-1) - edgeSize/2,
1.0f, 0.0f, 0.0f ) );
}
}
for( unsigned i=0; i<nVerticesPerEdge-1; ++i )
{
for( unsigned j=0; j<nVerticesPerEdge-1; ++j )
{
indices.push_back( (i)*nVerticesPerEdge + (j) );
indices.push_back( (i+1)*nVerticesPerEdge + (j) );
indices.push_back( (i+1)*nVerticesPerEdge + (j+1) );
indices.push_back( (i)*nVerticesPerEdge + (j) );
indices.push_back( (i+1)*nVerticesPerEdge + (j+1) );
indices.push_back( (i)*nVerticesPerEdge + (j+1) );
}
}
}
示例3:
ShapeEntity::ShapeEntity(const sf::Vector2f& velocity, const sf::Vector2f& acceleration, const sf::Vector2f& maxVelocity, const sf::Vector2f& accValues, const Vertices& vertices)
:Entity(velocity,acceleration,maxVelocity,accValues),
shape_(),
bounds_(){
if (vertices.size()>0)
setVertices(vertices);
}
示例4: drawTexture
void RenderBridge::drawTexture(std::shared_ptr<const Texture> texture, const Vertices& vertices)
{
loadTexture(*texture);
GLuint textureId = _textures.at(texture.get());
FloatList texturesBuffer(2*vertices.size());
FloatList verticesBuffer(3*vertices.size());
for(const Vertex& vertex : vertices)
{
Point p = vertex.position*_transform;
texturesBuffer.push_back(vertex.texture.x);
texturesBuffer.push_back(vertex.texture.y);
verticesBuffer.push_back(p.x);
verticesBuffer.push_back(p.y);
verticesBuffer.push_back(0);
}
glEnable(GL_TEXTURE_2D);
glEnableClientState( GL_TEXTURE_COORD_ARRAY );
glEnableClientState( GL_VERTEX_ARRAY );
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glBindTexture(GL_TEXTURE_2D, textureId);
glVertexPointer(3, GL_FLOAT, 0, &verticesBuffer.front() );
glTexCoordPointer(2, GL_FLOAT, 0, &texturesBuffer.front() );
glDrawArrays(GL_QUADS, 0, verticesBuffer.size()/3 );
glDisableClientState( GL_TEXTURE_COORD_ARRAY );
glDisableClientState( GL_VERTEX_ARRAY );
glDisable(GL_TEXTURE_2D);
glDisable(GL_BLEND);
glFlush();
#ifdef MVCGAME_DEBUG_DRAW
std::cout << ">>>>" << std::endl;
std::cout << "GlRenderBridge::drawTexture " << textureId << std::endl;
std::cout << "vertices " << vertices.size() << std::endl;
GLenum err = glGetError();
if(err != GL_NO_ERROR)
{
std::cout << "error " << err << std::endl;
}
std::cout << "<<<<" << std::endl;
#endif
}
示例5:
Quadrangle2 Quadrangle3::getQuadrangle2(Vertices v, const CoordSystem3& coorSystem) {
Quadrangle2::Vertices vertices2;
for(size_t i = 0; i < v.size(); ++i) {
mCoordSystem.convertTo(v[i]);
vertices2[i] = {v[i].x(), v[i].y()};
}
return vertices2;
}
示例6: incorrect_input
int incorrect_input(std::string error = "")
{
std::cerr << "Incorrect input file.\n"
<< " " << error << "\n";
std::cerr << "So far: " << vertices.size() << " vertices, "
<< faces.size() << " faces\n";
return EXIT_FAILURE;
}
示例7: create
uint32_t DirectXInputLayoutRegistry::create(const Vertices& vertices)
{
TB::runtimeCheck(vertices.size() > 0);
const char* semantics[] = { "POSITION", "NORMAL", "TEXCOORD", "COLOR" };
const DXGI_FORMAT formats[] = { DXGI_FORMAT(0), DXGI_FORMAT_R32_FLOAT, DXGI_FORMAT_R32G32_FLOAT, DXGI_FORMAT_R32G32B32_FLOAT, DXGI_FORMAT_R32G32B32A32_FLOAT };
// Input layout elements
std::vector<D3D11_INPUT_ELEMENT_DESC> elements;
for (size_t i = 0; i < vertices.size(); i++)
{
const auto& stream = vertices[i];
elements.push_back({ semantics[(int)stream.semantic], (UINT)stream.usageIndex, formats[stream.elements], (UINT)i, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 });
}
// Hash the memory bytes of the element
uint32_t id = hash(reinterpret_cast<uint8_t*>(&elements[0]), elements.size() * sizeof(D3D11_INPUT_ELEMENT_DESC));
auto item = mRegistry.find(id);
if (item == mRegistry.end())
{
std::stringstream fakeVSCode;
const char* memberTypes[] = { nullptr, "float", "float2", "float3", "float4" };
// Create a fake vertex shader for the input layout
fakeVSCode << "struct VSInput";
fakeVSCode << "{";
for (size_t i = 0; i < vertices.size(); i++)
{
const auto& stream = vertices[i];
fakeVSCode << memberTypes[stream.elements] << " _" << i << " : " << semantics[(int)stream.semantic] << stream.usageIndex << ";";
}
fakeVSCode << "};";
fakeVSCode << "float4 MainVS(VSInput input) : SV_POSITION { return float4(0, 0, 0, 1); }";
DirectXShader fakeVS(mRenderer, DataChunk(fakeVSCode.str()), "MainVS", ShaderType::Vertex);
ComPtr<ID3D11InputLayout> inputLayout;
HRESULT hr = mRenderer->getDevice()->CreateInputLayout(&elements[0], (UINT)elements.size(), fakeVS.getBlob()->GetBufferPointer(), fakeVS.getBlob()->GetBufferSize(), inputLayout.getInitRef());
TB::runtimeCheck(hr == S_OK);
mRegistry.emplace(id, inputLayout);
}
return id;
}
示例8: setVertices
void ShapeEntity::setVertices(const Vertices& vertices){
shape_.setPointCount(vertices.size());
int i = 0;
for (auto& v : vertices){
shape_.setPoint(i, sf::Vector2f(v.x, v.y));
++i;
}
adjustBounds();
shape_.setTextureRect(static_cast<sf::IntRect>(bounds_));
}
示例9: expand_dyn
void expand_dyn(Vertices &R){// diff -> diff with no dyn
S[level].i1 = S[level].i1 + S[level - 1].i1 - S[level].i2;//diff
S[level].i2 = S[level - 1].i1;//diff
while((int)R.size()) {
if((int)Q.size() + R.back().d > (int)QMAX.size()){
Q.push_back(R.back().i); Vertices Rp; cut2(R, Rp);
if((int)Rp.size()){
if((float)S[level].i1 / ++pk < Tlimit) degree_sort(Rp);//diff
color_sort(Rp);
S[level].i1++, level++;//diff
expand_dyn(Rp);
level--;//diff
}
else if((int)Q.size() > (int)QMAX.size()) QMAX = Q;
Q.pop_back();
}
else return;
R.pop_back();
}
}
示例10: UnityMatrix
Plane::Plane( D3D::GraphicDevice &device,
const Material& material )
: device_(device),
vertexDeclaration_(device, DefaultVertexDeclaration),
vertexBuffer_(device),
indexBuffer_(device),
shader_(device, L"plane.vsh"),
material_(material)
{
Vertices vertices;
Indices indices;
InitVertices( vertices, indices );
nVertices_ = vertices.size();
nPrimitives_ = indices.size()/3;
vertexBuffer_.SetVertices( &vertices[0], vertices.size() );
indexBuffer_.SetIndices( &indices[0], indices.size() );
SetViewMatrix( UnityMatrix() );
SetProjectiveMatrix( UnityMatrix() );
}
示例11: createSphere
int ParticleSystem::createSphere(int numParticles, float maxspray, Vertices &vtx, Indices &ind)
{
int i;
Vector3f pos;
Vector3f norm;
Vector2f texCoord;
Vector4f colour;
Vector3f wander;
vtx.resize(numParticles);
std::cout << " the vector's size is: " << vtx.size() << std::endl;
std::cout << " the vector's capacity is: " << vtx.capacity() << std::endl;
std::cout << " the vector's maximum size is: " << vtx.max_size() << std::endl;
ind.resize(0);
srand(time(0));
float trad = 0.4; // Defines the starting point of the particles
/* Create a set of points which will be the particles */
/* This is similar to drawing a torus: we will sample points on the surface of the torus */
float u, v, w, theta, phi, spray; // Work variables
for (int i = 0; i < numParticles; i++){
// Randomly select two numbers to define a point on the torus
u = ((double) rand() / (RAND_MAX));
v = ((double) rand() / (RAND_MAX));
// Use u and v to define the point on the torus
theta = u * 2.0f*M_PI;
phi = v * 2.0f*M_PI;
norm = Vector3f(cos(theta)*cos(phi), sin(theta)*cos(phi), sin(phi));
pos = Vector3f(norm.x*trad, norm.y*trad, norm.z*trad);
colour = Vector4f(((float)i) / ((float)numParticles), 0.0f, 1.0f - (((float)i) / ((float)numParticles)), 1.0f);
texCoord = Vector2f(0, 0); //not used for particels
// Now sample a point on a sphere to define a direction for points to wander around
u = ((double) rand() / (RAND_MAX));
v = ((double) rand() / (RAND_MAX));
w = ((double) rand() / (RAND_MAX));
theta = u * 2*M_PI;
phi = acos(2.0*v * -1.0);
spray = maxspray*pow((float) w, (float) (1.0/3.0)); // Cubic root
wander = Vector3f(spray*sin(theta)*sin(phi), spray*cos(theta)*sin(phi), spray*cos(phi));
norm = wander;
vtx[i] = Vertex(pos, colour, norm, texCoord);
}
return(0);
}
示例12: Grow
void NavMesh::Grow(Vertices& vertices, float amount) {
std::vector<Vector2> normals;
normals.resize(vertices.size(), Vector2(0,0));
for(NavTriangle* t : triangles) {
for (int i=0; i<3; i++) {
if (!t->neighbors[i]) {
int index0 = t->corners[i];
int index1 = t->corners[i<2 ? i + 1 : 0];
Vector2 direction = vertices[index1] - vertices[index0];
Vector2 normal = { -direction.y, direction.x };
normal.Normalize();
normals[index0] += normal;
normals[index1] += normal;
}
}
}
for (int i=0; i<vertices.size(); i++) {
vertices[i] -= normals[i].Normalized() * amount;
}
}
示例13: print
void print()
{
std::cout << "MeshData:: " << std::endl << "Vertices : " << std::endl;
for (int i = 0; i < m_Vertices.size(); i++)
{
std::cout << i << ": " << m_Vertices[i] << std::endl;
}
std::cout << "Indices & Normals : " << std::endl;
for (int i = 0; i < m_Faces.size(); i++)
{
std::cout << i << ": " << m_Faces[i] << "\t n:" << m_Normals[i] << std::endl;
}
};
示例14: color_sort
void color_sort(Vertices &R){
int j = 0, maxno = 1, min_k = max((int)QMAX.size() - (int)Q.size() + 1, 1);
C[1].clear(), C[2].clear();
for(int i = 0; i < (int)R.size(); i++) {
int pi = R[i].i, k = 1;
while(cut1(pi, C[k])) k++;
if(k > maxno) maxno = k, C[maxno + 1].clear();
C[k].push_back(pi);
if(k < min_k) R[j++].i = pi;
}
if(j > 0) R[j - 1].d = 0;
for(int k = min_k; k <= maxno; k++)
for(int i = 0; i < (int)C[k].size(); i++)
R[j].i = C[k][i], R[j++].d = k;
}
示例15: UnityMatrix
Sphere::Sphere( float radius, unsigned tesselationLevel, D3D::GraphicDevice device, float freq,
const Material& material )
: device_(device),
vertexDeclaration_(device, DefaultVertexDeclaration),
vertexBuffer_(device),
indexBuffer_(device),
shader_(device, L"sphere.vsh"),
radius_(radius),
tesselationLevel_(tesselationLevel),
freq_(freq),
material_(material)
{
Vertices vertices;
Indices indices;
InitVertices(tesselationLevel, radius*sqrtf(2), vertices, indices);
nVertices_ = vertices.size();
nPrimitives_ = indices.size()/3;
vertexBuffer_.SetVertices( &vertices[0], vertices.size() );
indexBuffer_.SetIndices( &indices[0], indices.size() );
SetPositionMatrix( UnityMatrix() );
SetViewMatrix( UnityMatrix() );
SetProjectiveMatrix( UnityMatrix() );
}