# Access ObjLoader Data

**URL:** https://discourse.libcinder.org/t/access-objloader-data/1817
**Category:** Uncategorized
**Created:** [April 30, 2021, 9:02pm UTC](https://discourse.libcinder.org/t/access-objloader-data/1817 "2021-04-30T21:02:04Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![edselmalasig](https://avatars.discourse-cdn.com/v4/letter/e/ee7513/32.png) [@edselmalasig](https://discourse.libcinder.org/u/edselmalasig)
#### Post date: [April 30, 2021, 9:02pm UTC](https://discourse.libcinder.org/t/access-objloader-data/1817/1 "2021-04-30T21:02:04Z")

</div>

Hi I would like to know how to access the vertex position and indices using  
VBOMesh  
TriMesh  
ObjLoader.

PS Reply ASAP

---

<div class="post-metadata">

### Author: ![lithium](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.libcinder.org/lithium/32/38_2.png) [@lithium](https://discourse.libcinder.org/u/lithium)
#### Post date: [May 1, 2021, 3:27am UTC](https://discourse.libcinder.org/t/access-objloader-data/1817/2 "2021-05-01T03:27:07Z")

</div>

[https://www.libcinder.org/docs/classcinder\_1\_1\_tri\_mesh.html](https://www.libcinder.org/docs/classcinder_1_1_tri_mesh.html)

---

<div class="post-metadata">

### Author: ![rich.e](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.libcinder.org/rich.e/32/1025_2.png) [@rich.e](https://discourse.libcinder.org/u/rich.e)
#### Post date: [May 4, 2021, 2:54am UTC](https://discourse.libcinder.org/t/access-objloader-data/1817/3 "2021-05-04T02:54:46Z")

</div>

Here’s a snippet from a project I’m working on that pulls out some vertex data and indices from a `TriMesh`, to use them in a compute shader:

```auto
void MeshVolumizerApp::makeVertexBuffers()
{
	if( ! mMesh ) {
		CI_LOG_E( "no mesh loaded" );
		return;
	}

	if( ! mMesh->hasTexCoords() ) {
		CI_LOG_E( "mesh has no tex coords" );
		// will still process but texCoords will all be (0, 0)
	}

	// upload vertex data
	size_t numVertices = mMesh->getNumVertices();
	const auto &positions = mMesh->getPositions<3>();
	const auto &normals = mMesh->getNormals();
	vector<VertexData> vertData;
	for( size_t i = 0; i < numVertices; i++ ) {
		VertexData v;
		v.pos = vec4( positions[i], 0 );
		if( mMesh->hasTexCoords() ) {
			v.texCoord = vec4( mMesh->getTexCoords0<2>()[i], 0, 0 );
		}
		v.normal = vec4( normals[i], 0 );

		vertData.push_back( v );
	}

	mSsboVertexData = gl::Ssbo::create( vertData.size() * sizeof( VertexData ), vertData.data(), GL_STATIC_DRAW );

	// upload indices
	const auto &indices = mMesh->getIndices();
	vector<TriangleData> facesData;
	for( size_t i = 0; i < indices.size(); /* */ ) {
		TriangleData face;
		face.indices.x = indices[i++];
		face.indices.y = indices[i++];
		face.indices.z = indices[i++];
		face.indices.w = 0;

		facesData.push_back( face );
	}

	mSsboIndexData = gl::Ssbo::create( facesData.size() * sizeof( TriangleData ), facesData.data(), GL_STATIC_DRAW );
}

```

If you have more specific questions feel free to ask.

Cheers,  
Rich
