Skip to content

Commit

Permalink
add texture coordinates to addSurface mesh generator
Browse files Browse the repository at this point in the history
  • Loading branch information
fishuyo committed Aug 27, 2014
1 parent 83b6d69 commit 7e1d7ba
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions allocore/src/graphics/al_Shapes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,7 @@ int addSurface(Mesh& m, int Nx, int Ny, float width, float height){
for(int j=0; j<Ny; ++j){ float y=(float(j)/(Ny-1) - 0.5f) * height;
for(int i=0; i<Nx; ++i){ float x=(float(i)/(Nx-1) - 0.5f) * width;
m.vertex(x, y);
m.texCoord(float(i)/(Nx-1), float(j)/(Ny-1));
}}

// Note: the start and end points of each row are duplicated to create
Expand Down

3 comments on commit 7e1d7ba

@LancePutnam
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be better to create another function 'addSurfaceWithTexCoords'. Otherwise, it forces texcoords in the mesh even if you are not using them.

Overall, I think these shape generator functions (yes, my initiative) need to be rethought to allow a finer granularity of control without adding unnecessary overhead.

@fishuyo
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could have boolean flags with default values for both normals and texcoords to all the generators, or a single bitwise attribute argument to do the same..

@LancePutnam
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The bit flag is probably the best approach to future proof the API. Another thought would be to move to an object model to hide these parameters.

Please sign in to comment.