List of verticies from OpenGL program to something importable

Go To StackoverFlow.com

0

I'm working on making a new visualization of the type of binary stars I study, and I'm starting from an existing code that renders a nice view of them given some sensible physical parameters.

I would like a bit more freedom on the animation side of things, however, and my first thought was to output the models made by the program in a format that could be read in by something else (Blender?) I've read up on the (Wavefront?) .OBJ format, and while it seems straightforward, I can't seem to get it right; importing fails silently, and I suspect it's because I'm not understanding how the objects are actually stored.

The program I'm starting from is a C++ project called BinSim, and it already has a flag to output vertices to a log file for all the objects created. It seems pretty simple, just a list of indices, x, y, z, and R, G, B (sometimes A) values. An example output format I've been working with can be found here; Each object is divided up into a latitude/longitude grid of points, and this is a small snippet (full file is upwards of 180 MB for all the objects created).

I've been able to see that the objects are defined as triangle strips, but I'm confused enough by all of this that I can't see the clear path towards making this list of vertices into an .OBJ (or whatever) format. Sorry if this really belongs in another area (GameDev?), and thanks!

2012-04-05 23:38
by Ryan


0

OpenGL is not a scene management system. It's a drawing API and starting off OpenGL data structures for model storage is tedious. As already said, OpenGL draws things. There are several drawing primitives, the triangle strip being one of them. You start with two vertices (forming a line) and each next incoming vertex extends the line of the last two specified vertices to a triangle. The Wavefront OBJ format doesn't know triangle strips, you'd have to break them down into individual triangles, emulating the way OpenGL does it.

Also don't forget that Blender is easily extensible using Python scripting and you can just write a import script for whatever data you already have without going through the hassle of using some ill suited format.

2012-04-05 23:55
by datenwolf
Creating the models in a different way is beyond the scope of this project, since there's no reason to reinvent this particular wheel.

I was hoping for some specific tips in turning the triangle strips into something more usable. I know Blender is extensible and I can write an importer, and that's essentially what I'm trying to do - Ryan 2012-04-06 01:02

There's no connectivity information in that example output file Ryan. Is the first index [m] of [m][n] a strip index? If so you can generate individual triangles from the strip by iterating on n by one and emitting 3 vertices [m][n], [m][n+1] and [m][n+2] - Robinson 2012-04-06 02:17
Ads