QPaintedSphere3D::QPaintedSphere3D(const QVector3D ¢er, float radius, int rings, int slices) : _d(new QSphere3D(center, radius)), _rings(rings), _slices(slices), _facesColor(255, 255, 255, 255), _verticesColor(255, 255, 255, 255) { createVertices(_rings, _slices); updateMatrix(); }
GeodesicHemisphereMesh::GeodesicHemisphereMesh(unsigned level) { unsigned nv = (level + 1) * (level + 1) * 2; unsigned nf = level * level * 2 * 2; createVertices(nv); createIndices(nf * 3); Vector3F * p = vertices(); unsigned * idx = indices(); unsigned currentidx = 0; unsigned currentver = 0; Vector3F a(0.f, 1.f, 0.f); Vector3F b(-1.f, 0.001f, 0.f); Vector3F c(0.f, 0.001f, 1.f); Vector3F d(1.f, 0.001f, 0.f); Vector3F e(0.f, 0.001f, -1.f); subdivide(level, currentver, currentidx, p, idx, a, b, c, d); subdivide(level, currentver, currentidx, p, idx, a, d, e, b); printf("vertices count: %d\n", currentver); printf("indices count: %d\n", currentidx); }
int AttackParticlePolicy::update(float dt) { if(particles.size() == 0) { return 2; } int i = 0; for(ListNode<BaseParticle>* walker = particles.getFirst(); walker != NULL; walker = walker->next) { if(!walker->value.update(dt)) { i++; } } if(i > 0) recreateVertices = true; particles.remove(i); createVertices(); recreateVertices = false; return 1; }
///////////////////////////////////////////////////////// // // polygon // ///////////////////////////////////////////////////////// // Constructor // ///////////////////////////////////////////////////////// polygon :: polygon(t_floatarg numInputs) : GemShape(), m_numVertices(0), m_vertarray(NULL), m_vert(NULL), m_numInputs(0), m_inlet(NULL) { int i; int realNum = static_cast<int>(numInputs); // configure the inlets if(realNum>0) { createVertices(realNum); m_numInputs=realNum; m_inlet=new t_inlet*[m_numInputs]; char tempVt[7]; // create the proper number of inputs for (i = 0; i < realNum; i++) { sprintf(tempVt, "%d", i+1); m_inlet[i]=inlet_new(this->x_obj, &this->x_obj->ob_pd, &s_list, gensym(tempVt) ); } } else { logpost(NULL, 5, "variable number of vertices"); } }
void Model::updateBufferVertices() { // Create a triangle fan std::vector<float> vertices = createVertices(); // Copy the vertices to the buffer glBufferData(GL_ARRAY_BUFFER, vertices.size() * sizeof(float), &vertices[0], GL_STATIC_DRAW); }
Graph(std::map<int,Read*> reads,std::vector<Overlap*> overlaps){ createVertices(reads); createEdges(overlaps); std::cout <<toString()<<"\n"; removeEmptyVertices(); for(Vertex *v:vertices){ v->sortEdges(); } }
void QHull3d::initialize(const gk::Point* points, int count) { clear(); _points = points; _pointcount = count; createVertices(); createInitialTetrahedron(); }
Sphere::Sphere(float nRadius, float nStacks, float nSlices) :radius(nRadius) ,stacks(nStacks) ,slices(nSlices) { num_vertices = (nStacks + 1) * (nSlices + 1); num_index_elements = (nStacks) * (nSlices) * 4; vertices = new VertexPTNC[num_vertices]; index_elements = new int[num_index_elements]; createVertices(); createIndices(); };
void Toroid::init(){ vertCount = detail * segs; triFaceCount = vertCount*2; indicesCount = triFaceCount*3; allocateMemory(); createVertices(); createIndices(); createFaces(); createVertexNormals(); createCoords(); }
AbcMesh::AbcMesh(const char * filename) { std::cout<<"abc file "<<filename<<std::endl; createVertices(4); createIndices(6); Vector3F * p = vertices(); unsigned * idx = indices(); idx[0] = 0; idx[1] = 1; idx[2] = 2; idx[3] = 2; idx[4] = 3; idx[5] = 0; p[0].x = 0.f; p[0].y = 0.f; p[0].z = 2.f; p[1].x = 1.f; p[1].y = 0.f; p[1].z = 2.f; p[2].x = 1.f; p[2].y = 1.f; p[2].z = 2.f; p[3].x = 0.f; p[3].y = 1.f; p[3].z = 2.f; }
HRESULT ManagementSprite::initVertexBuffer(ID3D11Device* p_device) { HRESULT hr = S_OK; std::vector<Vertex_PT> vertices = createVertices(); D3D11_BUFFER_DESC vbd; vbd.Usage = D3D11_USAGE_DYNAMIC; vbd.ByteWidth = sizeof(Vertex_CP) * vertices.size(); vbd.BindFlags = D3D11_BIND_VERTEX_BUFFER; vbd.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; vbd.MiscFlags = 0; D3D11_SUBRESOURCE_DATA vinitData; vinitData.pSysMem = &vertices[0]; hr = p_device->CreateBuffer(&vbd, &vinitData, &m_vertexBuffer); if(FAILED(hr)) MessageBox(NULL, L"ManagmenetSprite::initVertexBuffer() | CreateBuffer() | Failed", L"Sprite VertexBuffer", MB_OK | MB_ICONEXCLAMATION); return hr; }
void polygon :: listMess(int argc, t_atom*argv) { if(0==m_numInputs) { if(argc%3) { error("list must contain 3 elements for each vertex!"); return; } createVertices(argc/3); } if(m_numVertices*3==argc) { int i=0; for(i=0; i<m_numVertices; i++) { setVert(i, atom_getfloat(argv+0), atom_getfloat(argv+1), atom_getfloat(argv+2) ); argv+=3; } } else { error("vertex-list must have exactly %d numbers", m_numVertices*3); } }
int main() { SDL_Init(SDL_INIT_VIDEO); SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2); SDL_Window* window = SDL_CreateWindow("OpenGL", 100, 100, 800, 600, SDL_WINDOW_OPENGL); SDL_GLContext context = SDL_GL_CreateContext(window); // Initialize GLEW glewExperimental = GL_TRUE; glewInit(); GLuint vao = createVao(); GLuint vbo = createVertices(); GLuint ebo = createElements(); // Create and compile the vertex shader GLuint vertexShader = glCreateShader(GL_VERTEX_SHADER); glShaderSource(vertexShader, 1, &vertexSource, NULL); glCompileShader(vertexShader); // Create and compile the fragment shader GLuint fragmentShader = glCreateShader(GL_FRAGMENT_SHADER); glShaderSource(fragmentShader, 1, &fragmentSource, NULL); glCompileShader(fragmentShader); // Link the vertex and fragment shader into a shader program GLuint shaderProgram = glCreateProgram(); glAttachShader(shaderProgram, vertexShader); glAttachShader(shaderProgram, fragmentShader); glBindFragDataLocation(shaderProgram, 0, "outColor"); glLinkProgram(shaderProgram); glUseProgram(shaderProgram); // Specify the layout of the vertex data GLint posAttrib = glGetAttribLocation(shaderProgram, "position"); glEnableVertexAttribArray(posAttrib); glVertexAttribPointer(posAttrib, 2, GL_FLOAT, GL_FALSE, 5 * sizeof(GLfloat), 0); GLint colAttrib = glGetAttribLocation(shaderProgram, "color"); glEnableVertexAttribArray(colAttrib); glVertexAttribPointer(colAttrib, 3, GL_FLOAT, GL_FALSE, 5 * sizeof(GLfloat), (void*)(2 * sizeof(GLfloat))); SDL_Event windowEvent; while (true) { if (SDL_PollEvent(&windowEvent)) { if (windowEvent.type == SDL_QUIT || (windowEvent.type == SDL_KEYUP && windowEvent.key.keysym.sym == SDLK_ESCAPE)) break; } // Clear the screen to black glClearColor(0.0f, 0.0f, 0.0f, 1.0f); glClear(GL_COLOR_BUFFER_BIT); // Draw a rectangle from the 2 triangles using 6 indices glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0); // Swap buffers SDL_GL_SwapWindow(window); } glDeleteProgram(shaderProgram); glDeleteShader(fragmentShader); glDeleteShader(vertexShader); glDeleteBuffers(1, &ebo); glDeleteBuffers(1, &vbo); glDeleteVertexArrays(1, &vao); SDL_GL_DeleteContext(context); }
QPaintedSphere3D::QPaintedSphere3D() : _d(new QSphere3D()), _rings(12), _slices(12), _facesColor(255, 255, 255, 255), _verticesColor(255, 255, 255, 255) { createVertices(_rings, _slices); }
// 初期化. IZ_BOOL DynamicStreamApp::InitInternal( izanagi::IMemoryAllocator* allocator, izanagi::graph::CGraphicsDevice* device, izanagi::sample::CSampleCamera& camera) { IZ_BOOL result = IZ_TRUE; // Vertex Buffer. createVBForDynamicStream(allocator, device); createVBForMapUnmap(allocator, device); { izanagi::graph::SVertexElement elems[] = { { 0, 0, izanagi::graph::E_GRAPH_VTX_DECL_TYPE_FLOAT4, izanagi::graph::E_GRAPH_VTX_DECL_USAGE_POSITION, 0 }, { 0, 16, izanagi::graph::E_GRAPH_VTX_DECL_TYPE_COLOR, izanagi::graph::E_GRAPH_VTX_DECL_USAGE_COLOR, 0 }, }; m_vd = device->CreateVertexDeclaration(elems, COUNTOF(elems)); } { { izanagi::CFileInputStream in; in.Open("shader/vs.glsl"); std::vector<IZ_BYTE> buf(in.GetSize() + 1); in.Read(&buf[0], 0, buf.size()); buf[buf.size() - 1] = 0; m_vs = device->CreateVertexShader(&buf[0]); } { izanagi::CFileInputStream in; in.Open("shader/ps.glsl"); std::vector<IZ_BYTE> buf(in.GetSize() + 1); in.Read(&buf[0], 0, buf.size()); buf[buf.size() - 1] = 0; m_ps = device->CreatePixelShader(&buf[0]); } m_shd = device->CreateShaderProgram(); m_shd->AttachVertexShader(m_vs); m_shd->AttachPixelShader(m_ps); } // カメラ camera.Init( izanagi::math::CVector4(0.0f, 0.0f, 30.0f, 1.0f), izanagi::math::CVector4(0.0f, 0.0f, 0.0f, 1.0f), izanagi::math::CVector4(0.0f, 1.0f, 0.0f, 1.0f), 1.0f, 500.0f, izanagi::math::CMath::Deg2Rad(60.0f), (IZ_FLOAT)device->GetBackBufferWidth() / device->GetBackBufferHeight()); camera.Update(); createVertices(); __EXIT__: if (!result) { ReleaseInternal(); } return IZ_TRUE; }
void CircleCurve::create() { createVertices(37); setRadius(1.f); }
Grid::Grid() : m_lineVBO(new RenderableObject) { createVertices(); }
void Grid::updateVBO() { createVertices(); }