model loading

Started by Rainer, May 20, 2008, 10:50:27

Previous topic - Next topic

Rainer

Hi there

Until now, my engine supported just static .obj models.
I now need to get animations into the engine, but i'm not sure how.
What model format would you recommend? What i read til now, md2 would be easy?
Unfortunately i did not find any simple example.
I work with blender, blender can export to md2 by deault, other idea is to support .blend files directly, has someone done this already?
How would you proceed?

Rainer

i need to display a lot of enemys at the same time, so my solution should have a good performance.
how should the rendering be done? one displaylist per animationframe? vertexbufferobject and then switching buffers? or rendering directly with opengl commands?

paulscode

I do not have any experience with this myself, but I do know that the jpct engine uses the .md2 format for animations.  Egon might be able to give you some ideas.  His website is at http://www.jpct.net

bobjob

Just continue on what you are currently using.

I personally fiddle with md2 in blender then export the keyframes (as animation) to .obj

also you can generate between frames, to give it a smoother look when animating. by finding the difference between the points.

display lists are fine. but i tend 2 use vbo's and only fall back on display lists if vbo's are'nt supported.

just create a seperate displayList, or VBO, for each frame. anything more than that tends to be a big perforamce hit. if your going to have plenty of enemies the last thing you want is to be using is skeletons.

Rainer

Thanks for the hints.
I also thougt about a solution like you are suggesting, just had e bit fear from the time it takes to export all de keyframes for a complex animation.
But since its possible to write blender export plugins this could be solved.
So I would export the keyframes to .obj, then calculate subframes to smooth the animation, and put every frame into a display list.
What was your intention to use vbo instead of display lists?

bobjob

For some reason laptop Radeon spikes when i use Display Lists. So by default i use speedy VBO's.

Rainer

Quote from: bobjob on May 21, 2008, 01:37:40
also you can generate between frames, to give it a smoother look when animating. by finding the difference between the points.
how did you do this with the normals?
for the vertices/faces it seems to work fine, but my normals totally get messed up  ???

bobjob

This is the code for the normals, i use floatbuffers to store all my points

for (int b = 0; b < start.nor.capacity(); b++) {
					nor.put(b, start.nor.get(b) + (((end.nor.get(b) - start.nor.get(b)) / (frames+1)) * (currentFrame+1)));
				}
				normalize(objData.nor);


  public static void normalize(FloatBuffer v){
	  int total = v.capacity() / 3;
	  for (int i = 0; i < total; i+=3) {
		  float length = (float)Math.sqrt(
				  	(v.get(i)  *v.get(i)  )
				  + (v.get(i+1)*v.get(i+i))
				  + (v.get(i+2)*v.get(i+2)) );
		    if(length <.00001f) {
		    	v.put(i, 0);
		    	v.put(i+1, 0);
		    	v.put(i+1, 0);
		    } else {
		    	v.put(i, v.get(i)/length);
		    	v.put(i+1, v.get(i+1)/length);
		    	v.put(i+2, v.get(i+2)/length);
		    }
	  }
  }


I use that for normals

Rainer

seems we're basically doing the same thing.

i now exportet every single frame from blender, and noticed that the number of normals in the files is diffrent, how can this happen?
Maybe the bug i get is just because of an indexing error?

bobjob

if you are exporting for some quake 2 md2's the normals should be equal in each frame.

Rainer

i tryed to export directly from my .blend to .obj, not converting first to md2.
exporting my model to md2 fails with "Model has a face without texture map", but i don't know why, guess i have to investigate my model...

bobjob

oh, i have never made an md2, i just fiddle with the objects that are md2, then export as a obj animation. i got a whole bunch of old quake2 models

Rainer

well, since blender 2.46 changed the uv unwrapping i anyway have to re-learn this :p
hope i get it to work somehow.