OpenCTM (I guess OpenCTM means Open Compressed Triangle Mesh) is a file format for storing 3D triangle meshes in a compact and versatile format. The format supports per-vertex position, normal, texture coordinates and custom attributes. Large geometries up to billions of triangles and vertices can be stored (OpenCTM uses 32-bit face indices). The OpenCTM SDk is open source and written in C.
You can download the OpenCTM SDK HERE.
Here is how to load a ctm file:
#includeCTMcontext context; CTMuint vertCount, triCount, * indices; CTMfloat * vertices; // Create a new context context = ctmNewContext(CTM_IMPORT); // Load the OpenCTM file ctmLoad(context, "mymesh.ctm"); if(ctmGetError(context) == CTM_NONE) { // Access the mesh data vertCount = ctmGetInteger(context, CTM_VERTEX_COUNT); vertices = ctmGetFloatArray(context, CTM_VERTICES); triCount = ctmGetInteger(context, CTM_TRIANGLE_COUNT); indices = ctmGetIntegerArray(context, CTM_INDICES); // Deal with the mesh (e.g. transcode it to our // internal representation) // ... } // Free the context ctmFreeContext(context);
and here is how to create a ctm file from your geometry.
#includeCTMcontext context; CTMuint vertCount, triCount, * indices; CTMfloat * vertices; // Create our mesh in memory vertCount = 100; triCount = 120; vertices = (CTMfloat*)malloc(3*sizeof(CTMfloat)*vertCount); indices = (CTMuint*)malloc(3*sizeof(CTMuint)*triCount); // ... // Create a new context context = ctmNewContext(CTM_EXPORT); // Define our mesh representation to OpenCTM (store // references to it in the context) ctmDefineMesh(context, vertices, vertCount, indices, triCount, NULL); // Save the OpenCTM file ctmSave(context, "mymesh.ctm"); // Free the context ctmFreeContext(context); // Free our mesh free(indices); free(vertices);
I’ll try to add it in GeeXLab…
cool,will try it too 🙂
Ultimately, I will have to wait and see whether or not it sees sufficient uptake to justify using it in my own projects.
Anyone know how to or where I can find a tutorial on coding plug ins for Milkshape3d? This would be cool to add to milkshape3d as a plug in so one could calculate Tangent and Bitangent vectors…
Pingback: GeeXLab: Laboratory for Real Time 3D Learning and Experiments | The Geeks Of 3D - 3D Tech News
Pingback: OpenCTM 1.0.2: Compressed 3D Meshes SDK Available | The Geeks Of 3D - 3D Tech News