0

I'm reading obj files from Blender and trying to load in an animation. (lots of vertices, 1 file for each frame)

For performance... Is it bad to create your own animation class, using this method to store frames?

vector <vector <float>> frames;
vector <float> verticesForThisFrame;
verticesForThisFrame.push_back(readX());
verticesForThisFrame.push_back(readY());
verticesForThisFrame.push_back(readZ());
frames.push_back(verticesForThisFrame);

If it's very inefficient, what do you suggest I do?

By the way, I use SDL to open a window, and OpenGL for graphics.

karlphillip
  • 92,053
  • 36
  • 243
  • 426
Aleksander Fimreite
  • 1,439
  • 2
  • 18
  • 31
  • may help you to understand in which way you need move https://stackoverflow.com/questions/2122684/how-to-import-blender-3d-animation-to-iphone-opengl-es?rq=1 – Volodymyr B. Apr 11 '14 at 09:48
  • Have a look at [ogl.dev's tutorial 38](http://ogldev.atspace.co.uk/www/tutorial38/tutorial38.html) for skeletal animations with ASSIMP library using the COLLADA file format. It is probably the most popular tutorial for skeletal animations. – jackw11111 Dec 18 '20 at 02:58

2 Answers2

0

Wavefront Obj have no animation support. Rendering different mesh for each frame as the blender export suggest you to do is quite a brute force patch, especially for heavy models.

If you want to keep your mesh in obj, you could create helpers (dummy points, lines, pathes etc) in blenders and named them. but the final animation should keep the same meshes transformed using maybe those helpers.

For an export format that handle animations, i would use collada.

Community
  • 1
  • 1
j-p
  • 1,622
  • 10
  • 18
  • Ok, so what is a better way of doing it than using the obj files? Or the best way preferably ;) – Aleksander Fimreite Apr 10 '14 at 20:49
  • I faced the same situation than you, and I opt for the one I've explained (making dummy named vertices for rotation axis and so on..). I've not search for more advanced export format. – j-p Apr 10 '14 at 20:56
  • googling a bit,a priori, i would choose [.x](http://stackoverflow.com/questions/19323192/skeletal-animation-of-directx-files-in-opengl) – j-p Apr 10 '14 at 21:06
0

1 file per frame ? i think the latency is the io , why don't you read all the frame at first ? i wonder how many vertices approximately in your frame , i look my sample character have about 6*10^4 vertices ,if only store vertices about used 4 * 3 * n(vertices) byte , my charcacter about 720KB per frame ,i will use 72 MB memory for 100 frame buffer to store it .

last, and .obj ? i think you should use binary file to store the data

Xuweirong
  • 23
  • 4