Personal License


  • Perpetual license (does not expire)
  • 1 application
  • Can distribute binary products only
  • Commercial use allowed
$4.99 Read License

Developer License


  • Perpetual license (does not expire)
  • Unlimited projects
  • Can distribute code and binary products
  • Commercial use allowed
$24.99 Read License

14 Day money-back guarantee

Full refund within 14 days of purchase date.

You need to log-in or create an account
  • Create an account
  • Log-in

Please use your real name.

Activation link will be sent to this address.

Minimum 8 characters

Enter your password again

Clicking this button confirms you read and agreed to the terms of use and privacy policy.

Dynamic vertex array

Dynamic vertex array
Developed by vincenzo panella, Released May 26, 2011

An STL-like class for handling array of vertexes easily and efficiently.

C/C++

Tags: 2d , 3d , array , fast

This class stores vertex co-ordinates in any dimension, either 2D co-ordinates, 3D coordinates, or higher dimensional co-ordinates. The class is useful for storing vertex co-ordinates for handling 3D or 2D meshes employed in games. It is ready to be included in any project with minimal refactoring, and is not dependent on any external libraries.

Example of usage :

CVertexList Array;

First it is needed to reserve enough space, in this case a 4 entry array. The second parameter is the stride, and in the example we allocate 4 vertexes each consisting of 3 co-ordinates, with 16 being the growth factor (more on that later on).

Array.Reserve( 4, 3, 16 ); 

Insert a vertex in the following manner:

float v[3]= { 10,10,10 };

Array.PushBack ( v );

You can add as many vertices as you wish. When the reserved size is reached, the array auto expands by the growth factor and reallocates itself, preserving the data. This is behavior is very similar to STL.

Array.ComputeBoundingBox( BMin, BMax );

Computes the bounding box of the vertex set created.

Array.ComputeCenter( Center );

Computes the the vertex set ' s centroid.

Additional helper functions are included, like positioning the entire vertex set or scaling up, a function for 'packing' the array eliminating unused space, query and 'settings' or 'gettings' functions are included as well.

Once you have created the vertex array you can get a low level access as follows:

float *ptr=Array.GetPtr();

int Vertices= Array.GetItemsCount();

for ( i=0; i

Note that the '3' factor is of vital importance because the vertex is stored in contiguous linear memory. With this class you get an STL-like rearranging vector with low level-linear memory access.

User Reviews

No reviews have been submitted yet.

Questions & Comments


Or enter your name and Email
No comments have been posted yet.
You must be logged-in to vote. Log-in to your account or register now.