# Export obj sequence from batch?

**URL:** <https://discourse.libcinder.org/t/export-obj-sequence-from-batch/417>\
**Category:** Using Cinder\
**Created:** [November 27, 2016, 6:23pm UTC](https://discourse.libcinder.org/t/export-obj-sequence-from-batch/417 "2016-11-27T18:23:18Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![eight\_io](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.libcinder.org/eight_io/32/57_2.png) [@eight\_io](https://discourse.libcinder.org/u/eight_io)\
**Post date:** [November 27, 2016, 6:23pm UTC](https://discourse.libcinder.org/t/export-obj-sequence-from-batch/417/1 "2016-11-27T18:23:18Z")

</div>

I am animating vertices (using an audio input in a vertex shader) of a geometry using a batch. I need to import this animation into a 360 video, so I thought it would be cool if I could export the batch being drawn into a 3d object sequence, which I could then import into a compositing software.

```auto
TriMeshRef triMesh = Trimesh::create(batch->getVboMesh()); //something like that
ObjLoader::write( writeFile( "~/output.obj" ), triMesh );

```

Is the above possible in principle and will the resulting triMesh capture the frame state of the vertices?

Thanks.

---

<div class="post-metadata">

**Author:** ![sharkbox](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.libcinder.org/sharkbox/32/39_2.png) [@sharkbox](https://discourse.libcinder.org/u/sharkbox)\
**Post date:** [November 27, 2016, 6:56pm UTC](https://discourse.libcinder.org/t/export-obj-sequence-from-batch/417/2 "2016-11-27T18:56:07Z")

</div>

It won’t output them if you’re moving them in a vertex shader unfortunately since it’s just translated on the GPU side. You’d need to update the trimesh itself on the CPU side, and then it would save correctly.

If you want to still use a shader, check out the TransformFeedback sample which I believe will allow a shader to affect your CPU buffer.

---

<div class="post-metadata">

**Author:** ![paul.houx](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.libcinder.org/paul.houx/32/31_2.png) [@paul.houx](https://discourse.libcinder.org/u/paul.houx)\
**Post date:** [November 27, 2016, 8:04pm UTC](https://discourse.libcinder.org/t/export-obj-sequence-from-batch/417/3 "2016-11-27T20:04:35Z")

</div>

Another consideration: there is no OBJ export from Cinder, so you’d have to roll your own or find a library that can do it for you. Also, the OBJ format is very limited and slow to import. Instead of OBJ, you could export and import using `TriMesh::read` and `TriMesh::write`. The data will be written to a binary file that is much quicker to import.

-Paul

---

<div class="post-metadata">

**Author:** ![eight\_io](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.libcinder.org/eight_io/32/57_2.png) [@eight\_io](https://discourse.libcinder.org/u/eight_io)\
**Post date:** [November 27, 2016, 8:17pm UTC](https://discourse.libcinder.org/t/export-obj-sequence-from-batch/417/4 "2016-11-27T20:17:30Z")

</div>

@paul.houx There is cinder:writeObj method –– I assume it exports trimeshes as obj files. No?

@sharkbox As far as getting triMesh out of VboMesh, I hoped it would be possible to download to CPU the current state of the mesh, similarly to how one can create a Surface out of a Texture.

–8

---

<div class="post-metadata">

**Author:** ![paul.houx](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.libcinder.org/paul.houx/32/31_2.png) [@paul.houx](https://discourse.libcinder.org/u/paul.houx)\
**Post date:** [November 27, 2016, 9:49pm UTC](https://discourse.libcinder.org/t/export-obj-sequence-from-batch/417/5 "2016-11-27T21:49:59Z")

</div>

> There is cinder:writeObj method

I stand corrected 🙂
