本文整理汇总了C++中VertexArray类的典型用法代码示例。如果您正苦于以下问题:C++ VertexArray类的具体用法?C++ VertexArray怎么用?C++ VertexArray使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了VertexArray类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: m_material
Disk::Disk(Graphics::Renderer *r, RefCountedPtr<Material> material, Graphics::RenderState *state, const int edges, const float rad)
: m_material(material)
{
PROFILE_SCOPED()
m_renderState = state;
VertexArray vertices (ATTRIB_POSITION);
vertices.Add(vector3f(0.f, 0.f, 0.f));
const float edgeStep = 360.0f / float(edges);
for (int i = edges; i >= 0; i--) {
vertices.Add(vector3f(
0.f+sinf(DEG2RAD(i*edgeStep))*rad,
0.f+cosf(DEG2RAD(i*edgeStep))*rad,
0.f));
}
SetupVertexBuffer(vertices, r);
}
开发者ID:lwho,项目名称:pioneer,代码行数:19,代码来源:Drawables.cpp
示例2: AddLinePoint
void AiCarStandard::AddLinePoint(VertexArray & va, const Vec3 & p)
{
int vsize;
const float* vbase;
va.GetVertices(vbase, vsize);
if (vsize == 0)
{
int vcount = 3;
float verts[3] = {p[0], p[1], p[2]};
va.SetVertices(verts, vcount, vsize);
}
else
{
int vcount = 6;
float verts[6] = {p[0], p[1], p[2], p[0], p[1], p[2]};
va.SetVertices(verts, vcount, vsize);
}
}
开发者ID:polyblank2,项目名称:vdrift,代码行数:19,代码来源:ai_car_standard.cpp
示例3: PROFILE_SCOPED
Disk::Disk(Graphics::Renderer *r, Graphics::RenderState *state, const Color &c, float rad)
{
PROFILE_SCOPED()
m_renderState = state;
VertexArray vertices (ATTRIB_POSITION);
m_material.Reset(r->CreateMaterial(MaterialDescriptor()));
m_material->diffuse = c;
vertices.Add(vector3f(0.f, 0.f, 0.f));
for (int i = 72; i >= 0; i--) {
vertices.Add(vector3f(
0.f+sinf(DEG2RAD(i*5.f))*rad,
0.f+cosf(DEG2RAD(i*5.f))*rad,
0.f));
}
SetupVertexBuffer(vertices, r);
}
开发者ID:lwho,项目名称:pioneer,代码行数:19,代码来源:Drawables.cpp
示例4: pos
bool CarGraphics::LoadLight(
const PTree & cfg,
ContentManager & content,
std::ostream & error_output)
{
float radius;
std::string radiusstr;
Vec3 pos(0), col(0);
if (!cfg.get("position", pos, error_output)) return false;
if (!cfg.get("color", col, error_output)) return false;
if (!cfg.get("radius", radius, error_output)) return false;
cfg.get("radius", radiusstr);
lights.push_back(Light());
SceneNode & bodynoderef = topnode.GetNode(bodynode);
lights.back().node = bodynoderef.AddNode();
SceneNode & node = bodynoderef.GetNode(lights.back().node);
node.GetTransform().SetTranslation(Vec3(pos[0], pos[1], pos[2]));
std::shared_ptr<Model> mesh;
if (!content.get(mesh, "", "cube" + radiusstr))
{
VertexArray varray;
varray.SetToUnitCube();
varray.Scale(radius, radius, radius);
content.load(mesh, "", "cube" + radiusstr, varray);
}
models.insert(mesh);
keyed_container <Drawable> & dlist = node.GetDrawList().lights_omni;
lights.back().draw = dlist.insert(Drawable());
Drawable & draw = dlist.get(lights.back().draw);
draw.SetColor(col[0], col[1], col[2]);
draw.SetModel(*mesh);
draw.SetCull(true);
draw.SetDrawEnable(false);
return true;
}
开发者ID:JanneSalokoski,项目名称:vdrift,代码行数:42,代码来源:cargraphics.cpp
示例5: if
VertexArray VertexArray::operator+ (const VertexArray & v) const
{
VertexArray out;
COMBINEVECTORS(colors);
COMBINEVECTORS(normals);
COMBINEVECTORS(vertices);
int idxoffset = vertices.size() / 3;
out.faces.reserve(faces.size() + v.faces.size());
out.faces.insert(out.faces.end(), faces.begin(), faces.end());
for (size_t i = 0; i < v.faces.size(); i++)
{
out.faces.push_back(v.faces[i]+idxoffset);
}
int maxtcsets = GetTexCoordSets();
if (v.GetTexCoordSets() > maxtcsets)
maxtcsets = v.GetTexCoordSets();
int tcsets1 = GetTexCoordSets();
int tcsets2 = v.GetTexCoordSets();
out.SetTexCoordSets(maxtcsets);
for (int i = 0; i < maxtcsets; i++)
{
if (i >= tcsets1 && i < tcsets2)
{
out.texcoords[i] = v.texcoords[i];
}
else if (i < tcsets1 && i >= tcsets2)
{
out.texcoords[i] = texcoords[i];
}
else if (i < tcsets1 && i < tcsets2)
{
COMBINEVECTORS(texcoords[i]);
}
}
return out;
}
开发者ID:HaohaoLau,项目名称:vdrift,代码行数:42,代码来源:vertexarray.cpp
示例6:
VertexArray<float>*
Model::getVArrayPtr(MetaGroup* _grp)
{
VertexArray<float>* va = new VertexArray<float>(4);
va->mData = new float[_grp->nVertices*4];
va->stride = 4*sizeof(float);
va->size = _grp->nVertices;
size_t posCount = 0;
vector<Face*>::const_iterator face_it;
for (face_it = _grp->fPtrList.begin(); face_it != _grp->fPtrList.end(); ++face_it){
vector<V3f *>::const_iterator v_it;
for (v_it=(*face_it)->vertexPtrList.begin(); v_it!=(*face_it)->vertexPtrList.end(); ++v_it){
va->mData[posCount++] = (*v_it)->getX();
va->mData[posCount++] = (*v_it)->getY();
va->mData[posCount++] = (*v_it)->getZ();
va->mData[posCount++] = mPriCTable.calculateTexCoord(mPriCTable.addColori(_grp->getMat()));
}
}
va->setBB(*_grp->bb);
return va;
}
开发者ID:Rowanion,项目名称:ooccollider,代码行数:21,代码来源:Model.cpp
示例7: Fill
void Starfield::Fill(unsigned long seed)
{
VertexArray *va = m_model->GetSurface(0)->GetVertices();
va->Clear(); // clear if previously filled
// Slight colour variation to stars based on seed
MTRand rand(seed);
//fill the array
for (int i=0; i<BG_STAR_MAX; i++) {
float col = float(rand.Double(0.2,0.7));
// this is proper random distribution on a sphere's surface
const float theta = float(rand.Double(0.0, 2.0*M_PI));
const float u = float(rand.Double(-1.0, 1.0));
va->Add(vector3f(
1000.0f * sqrt(1.0f - u*u) * cos(theta),
1000.0f * u,
1000.0f * sqrt(1.0f - u*u) * sin(theta)
), Color(col, col, col, 1.f)
);
}
}
开发者ID:HeadHunterEG,项目名称:pioneer,代码行数:23,代码来源:Background.cpp
示例8: draw
void draw(const VertexArray &varray, const IndexArray &iarray) {
load_xform_matrices();
bool use_vbo = !varray.get_dynamic() && sys_caps.vertex_buffers;
bool use_ibo = false;//!iarray.get_dynamic() && sys_caps.vertex_buffers;
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_COLOR_ARRAY);
glEnableClientState(GL_NORMAL_ARRAY);
if(use_vbo) {
Vertex v;
glBindBuffer(GL_ARRAY_BUFFER_ARB, varray.get_buffer_object());
glVertexPointer(3, GL_SCALAR_TYPE, sizeof(Vertex), (void*)((char*)&v.pos - (char*)&v));
glNormalPointer(GL_SCALAR_TYPE, sizeof(Vertex), (void*)((char*)&v.normal - (char*)&v));
glColorPointer(4, GL_SCALAR_TYPE, sizeof(Vertex), (void*)((char*)&v.color - (char*)&v));
for(int i=0; i<MAX_TEXTURES; i++) {
select_texture_unit(i);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
int dim = ttype[i] == TEX_1D ? 1 : (ttype[i] == TEX_3D || ttype[i] == TEX_CUBE ? 3 : 2);
glTexCoordPointer(dim, GL_SCALAR_TYPE, sizeof(Vertex), (void*)((char*)&v.tex[coord_index[i]] - (char*)&v));
}
glBindBuffer(GL_ARRAY_BUFFER_ARB, 0);
} else {
glVertexPointer(3, GL_SCALAR_TYPE, sizeof(Vertex), &varray.get_data()->pos);
glNormalPointer(GL_SCALAR_TYPE, sizeof(Vertex), &varray.get_data()->normal);
glColorPointer(4, GL_SCALAR_TYPE, sizeof(Vertex), &varray.get_data()->color);
for(int i=0; i<MAX_TEXTURES; i++) {
select_texture_unit(i);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
int dim = ttype[i] == TEX_1D ? 1 : (ttype[i] == TEX_3D || ttype[i] == TEX_CUBE ? 3 : 2);
glTexCoordPointer(dim, GL_SCALAR_TYPE, sizeof(Vertex), &varray.get_data()->tex[coord_index[i]]);
}
}
if(use_ibo) {
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER_ARB, iarray.get_buffer_object());
glDrawElements(primitive_type, iarray.get_count(), GL_UNSIGNED_INT, 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER_ARB, 0);
} else {
glDrawElements(primitive_type, iarray.get_count(), GL_UNSIGNED_INT, iarray.get_data());
}
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_COLOR_ARRAY);
glDisableClientState(GL_NORMAL_ARRAY);
for(int i=0; i<MAX_TEXTURES; i++) {
select_texture_unit(i);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
}
}
开发者ID:BackupTheBerlios,项目名称:engfx3d-svn,代码行数:57,代码来源:3denginefx.cpp
示例9: drawVertArray
void drawVertArray(GLenum shape,const VertexArray& varr) {
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_COLOR_ARRAY);
glEnableClientState(GL_NORMAL_ARRAY);
glVertexPointer(3,GL_FLOAT,sizeof(Vertex),&varr[0].loc[0]);
glColorPointer(3,GL_FLOAT,sizeof(Vertex),&varr[0].color[0]);
glNormalPointer(GL_FLOAT,sizeof(Vertex),&varr[0].normal[0]);
glDrawArrays(shape,0,varr.size());
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_COLOR_ARRAY);
glDisableClientState(GL_NORMAL_ARRAY);
}
开发者ID:jpdoyle,项目名称:JackOfClubs,代码行数:15,代码来源:Vertex.cpp
示例10: Particle
Particle(const VertexShader& vs, FragmentShader&& frag)
: sphere_instr(make_sphere.Instructions())
, sphere_indices(make_sphere.Indices())
, fs(std::forward<FragmentShader>(frag))
{
// attach the shaders to the program
prog.AttachShader(vs);
prog.AttachShader(fs);
// link and use it
prog.Link();
prog.Use();
projection_matrix = (prog/"ProjectionMatrix");
camera_matrix = (prog/"CameraMatrix");
model_matrix = (prog/"ModelMatrix");
light_pos = (prog/"LightPos");
// bind the VAO for the sphere
sphere.Bind();
const GLuint n_attr = 2;
// pointers to the vertex attribute data build functions
typedef GLuint (shapes::Sphere::*Func)(std::vector<GLfloat>&) const;
Func func[n_attr] = {
&shapes::Sphere::Positions,
&shapes::Sphere::Normals,
};
// managed references to the VBOs
Reference<Buffer> vbo[n_attr] = {verts, normals};
// vertex attribute identifiers from the shaders
const GLchar* ident[n_attr] = {"Position", "Normal"};
for(GLuint i=0; i!=n_attr; ++i)
{
// bind the VBO
vbo[i].Bind(Buffer::Target::Array);
// make the data
std::vector<GLfloat> data;
GLuint n_per_vertex = (make_sphere.*func[i])(data);
// upload the data
Buffer::Data(Buffer::Target::Array, data);
// setup the vertex attrib
VertexArrayAttrib attr(prog, ident[i]);
attr.Setup<GLfloat>(n_per_vertex);
attr.Enable();
}
}
开发者ID:xubingyue,项目名称:oglplus,代码行数:47,代码来源:019_helium.cpp
示例11: setVertices
void QuadPrimitive::setVertices(const VertexArray& arr)
{
osg::Vec3 vec = { 0.0f, 0.0f, 0.0f };
int i = 0;
for ( i = 0; i < arr.size(); i++)
{
(*m_vertexArray)[i].set(arr[i].getX(),arr[i].getY(),arr[i].getZ());
vec += {arr[i].getX(), arr[i].getY(), arr[i].getZ()};
}
m_center = vec / 4.0;
m_height = ((*m_vertexArray)[1] - (*m_vertexArray)[0]).length();
m_width = ((*m_vertexArray)[2] - (*m_vertexArray)[1]).length();
m_vertexArray->dirty();
_geometry->dirtyBound();
_outLine->dirtyBound();
}
开发者ID:LeonardoTech,项目名称:FunctionalUtilities,代码行数:17,代码来源:QuadPrimitive.cpp
示例12: TorusExample
TorusExample(void)
: make_torus(1.0, 0.5, 36, 24)
, torus_instr(make_torus.Instructions())
, torus_indices(make_torus.Indices())
, prog(make_prog())
, projection_matrix(prog, "ProjectionMatrix")
, camera_matrix(prog, "CameraMatrix")
, model_matrix(prog, "ModelMatrix")
{
Uniform<Vec4f>(prog, "ClipPlane").Set(0.f, 0.f, 1.f, 0.f);
// bind the VAO for the torus
torus.Bind();
// bind the VBO for the torus vertices
verts.Bind(Buffer::Target::Array);
{
std::vector<GLfloat> data;
GLuint n_per_vertex = make_torus.Positions(data);
// upload the data
Buffer::Data(Buffer::Target::Array, data);
// setup the vertex attribs array for the vertices
VertexArrayAttrib attr(prog, "Position");
attr.Setup<GLfloat>(n_per_vertex);
attr.Enable();
}
// bind the VBO for the torus UV-coordinates
texcoords.Bind(Buffer::Target::Array);
{
std::vector<GLfloat> data;
GLuint n_per_vertex = make_torus.TexCoordinates(data);
// upload the data
Buffer::Data(Buffer::Target::Array, data);
// setup the vertex attribs array for the vertices
VertexArrayAttrib attr(prog, "TexCoord");
attr.Setup<GLfloat>(n_per_vertex);
attr.Enable();
}
//
gl.ClearColor(0.8f, 0.8f, 0.7f, 0.0f);
gl.ClearDepth(1.0f);
gl.FrontFace(make_torus.FaceWinding());
gl.Enable(Capability::DepthTest);
gl.Enable(Functionality::ClipDistance, 0);
}
开发者ID:AdamSimpson,项目名称:oglplus,代码行数:46,代码来源:017_clipped_torus.cpp
示例13: WriteIndices
unsigned int VertexBuffer::WriteIndices(
const VertexArray & va,
const unsigned int icount,
const unsigned int vcount,
std::vector<unsigned int> & index_buffer)
{
const unsigned int * faces = 0;
int fn;
va.GetFaces(faces, fn);
assert(icount + fn <= index_buffer.size());
unsigned int * ib = &index_buffer[icount];
for (int j = 0; j < fn; ++j)
{
ib[j] = faces[j] + vcount;
}
return icount + fn;
}
开发者ID:JanneSalokoski,项目名称:vdrift,代码行数:19,代码来源:vertexbuffer.cpp
示例14: Shape
Shape(const Shader& vs, const Shader& fs)
: shape_instr(make_shape.Instructions())
, shape_indices(make_shape.Indices())
, prog(make(vs, fs))
, projection_matrix(prog, "ProjectionMatrix")
, camera_matrix(prog, "CameraMatrix")
, model_matrix(prog, "ModelMatrix")
, light_pos(prog, "LightPos")
{
// bind the VAO for the shape
shape.Bind();
const GLuint n_attr = 3;
// pointers to the vertex attribute data build functions
typedef GLuint (ShapeMaker::*Func)(std::vector<GLfloat>&) const;
Func func[n_attr] = {
&ShapeMaker::Positions,
&ShapeMaker::Normals,
&ShapeMaker::TexCoordinates
};
// managed references to the VBOs
Reference<Buffer> vbo[n_attr] = {verts, normals, texcoords};
// vertex attribute identifiers from the shaders
const GLchar* ident[n_attr] = {"Position", "Normal", "TexCoord"};
for(GLuint i=0; i!=n_attr; ++i)
{
// bind the VBO
vbo[i].Bind(Buffer::Target::Array);
// make the data
std::vector<GLfloat> data;
GLuint n_per_vertex = (make_shape.*func[i])(data);
// upload the data
Buffer::Data(Buffer::Target::Array, data);
// setup the vertex attrib
VertexArrayAttrib attr(prog, ident[i]);
attr.Setup<GLfloat>(n_per_vertex);
attr.Enable();
}
}
开发者ID:AdamSimpson,项目名称:oglplus,代码行数:41,代码来源:020_shaded_objects.cpp
示例15: Shape
Shape(
const Program& prog,
const ShapeBuilder& builder
): make_shape(builder)
, shape_instr(make_shape.Instructions())
, shape_indices(make_shape.Indices())
, vbos(4)
{
// bind the VAO for the shape
vao.Bind();
typename ShapeBuilder::VertexAttribs vert_attr_info;
const GLchar* vert_attr_name[] = {
"Position",
"Normal",
"Tangent",
"TexCoord"
};
for(int va=0; va!=4; ++va)
{
const GLchar* name = vert_attr_name[va];
std::vector<GLfloat> data;
auto getter = vert_attr_info.VertexAttribGetter(data, name);
if(getter != nullptr)
try
{
// bind the VBO for the vertex attribute
vbos[va].Bind(Buffer::Target::Array);
GLuint npv = getter(make_shape, data);
// upload the data
Buffer::Data(Buffer::Target::Array, data);
// setup the vertex attribs array
VertexArrayAttrib attr(prog, name);
attr.Setup<GLfloat>(npv);
attr.Enable();
}
catch(Error&)
{ }
}
}
开发者ID:xubingyue,项目名称:oglplus,代码行数:40,代码来源:029_flares.cpp
示例16: RenderText
float TextDraw::RenderText(
const Font & font, const std::string & text,
float x, float y, float scalex, float scaley,
VertexArray & output_array)
{
output_array.Clear();
float cursorx = x;
float cursory = y + scaley / 4;
for (unsigned int i = 0; i < text.size(); ++i)
{
if (text[i] == '\n')
{
cursorx = x;
cursory += scaley;
}
else
{
cursorx += RenderCharacter(font, text[i], cursorx, cursory, scalex, scaley, output_array);
}
}
return cursorx;
}
开发者ID:HaohaoLau,项目名称:vdrift,代码行数:22,代码来源:text_draw.cpp
示例17: Render
void Render(const Mat4f& model)
{
prog.Use();
model_matrix.Set(model);
// bind the VAO
sphere.Bind();
// use the instructions to draw the sphere
// (this basically calls glDrawArrays* or glDrawElements*)
sphere_instr.Draw(sphere_indices);
}
开发者ID:xubingyue,项目名称:oglplus,代码行数:10,代码来源:019_helium.cpp
示例18: Shape
Shape(const Program& prog)
: vbos(4)
, point_count(4096) {
// bind the VAO for the shape
vao.Bind();
make_shape_1(prog, 0, "Position1");
make_shape_2(prog, 1, "Position2");
make_radiance(prog, 2, "Radiance1");
make_radiance(prog, 3, "Radiance2");
}
开发者ID:matus-chochlik,项目名称:oglplus,代码行数:11,代码来源:021_morphing.cpp
示例19: render
void Game::render() {
glClearColor( 0.1, 0.1, 0.1, 1.0 );
glClear( GL_COLOR_BUFFER_BIT );
RenderStates defRenderStates;
temp.resize( 4 );
temp.setPrimitiveType( PrimitiveType::PType_Quads );
temp[ 0 ].pos = Vec2f( 0, 0 );
temp[ 1 ].pos = Vec2f( 1, 0 );
temp[ 2 ].pos = Vec2f( 1, 1 );
temp[ 3 ].pos = Vec2f( 0, 1 );
m_renderer.draw( temp, defRenderStates );
if( m_gameState ) {
m_gameState->render( m_renderer, defRenderStates );
}
SDL_GL_SwapWindow( m_window );
}
开发者ID:Smeky,项目名称:Brick-Breaker,代码行数:21,代码来源:Game.cpp
示例20: Render
void Render(double time)
{
gl.Clear().ColorBuffer().DepthBuffer();
auto camera = CamMatrixf::Orbiting(
Vec3f(),
8.5,
FullCircles(time / 5.0),
Degrees(15 + (-SineWave(time/10.0)+1.0)* 0.5 * 75)
);
ModelMatrixf model =
ModelMatrixf::Translation(0.0f, 2.5f, 0.0) *
ModelMatrixf::RotationA(
Vec3f(1.0f, 1.0f, 1.0f),
FullCircles(time / 7.0)
);
plane_prog.Use();
plane_camera_matrix.Set(camera);
plane.Bind();
gl.DrawArrays(PrimitiveType::TriangleStrip, 0, 4);
shape_prog.Use();
shape_camera_matrix.Set(camera);
shape_model_matrix.Set(model);
shape.Bind();
shape_instr.Draw(shape_indices);
halo_prog.Use();
halo_camera_matrix.Set(camera);
halo_model_matrix.Set(model);
gl.DepthMask(false);
gl.Enable(Capability::Blend);
shape_instr.Draw(shape_indices);
gl.Disable(Capability::Blend);
gl.DepthMask(true);
}
开发者ID:AdamSimpson,项目名称:oglplus,代码行数:40,代码来源:026_shape_halo.cpp
注:本文中的VertexArray类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论