Rainer
Regular nerd
 
Posts: 71
|
 |
« on: May 20, 2008, 03:50:27 » |
|
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?
|
|
|
|
|
Logged
|
|
|
|
Rainer
Regular nerd
 
Posts: 71
|
 |
« Reply #1 on: May 20, 2008, 12:48:18 » |
|
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?
|
|
|
|
|
Logged
|
|
|
|
paulscode
Newbie

Posts: 39
|
 |
« Reply #2 on: May 20, 2008, 13:56:50 » |
|
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
|
|
|
|
|
Logged
|
|
|
|
bobjob
Prolific Timewaster
   
Posts: 335
LWJGL: WOW SO GOOD
|
 |
« Reply #3 on: May 20, 2008, 18:37:40 » |
|
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.
|
|
|
|
|
Logged
|
|
|
|
Rainer
Regular nerd
 
Posts: 71
|
 |
« Reply #4 on: May 21, 2008, 00:49:27 » |
|
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?
|
|
|
|
|
Logged
|
|
|
|
bobjob
Prolific Timewaster
   
Posts: 335
LWJGL: WOW SO GOOD
|
 |
« Reply #5 on: May 21, 2008, 02:17:18 » |
|
For some reason laptop Radeon spikes when i use Display Lists. So by default i use speedy VBO's.
|
|
|
|
|
Logged
|
|
|
|
Rainer
Regular nerd
 
Posts: 71
|
 |
« Reply #6 on: May 21, 2008, 15:20:29 » |
|
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 
|
|
|
|
|
Logged
|
|
|
|
bobjob
Prolific Timewaster
   
Posts: 335
LWJGL: WOW SO GOOD
|
 |
« Reply #7 on: May 22, 2008, 01:58:36 » |
|
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
|
|
|
|
|
Logged
|
|
|
|
Rainer
Regular nerd
 
Posts: 71
|
 |
« Reply #8 on: May 22, 2008, 02:31:46 » |
|
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?
|
|
|
|
|
Logged
|
|
|
|
bobjob
Prolific Timewaster
   
Posts: 335
LWJGL: WOW SO GOOD
|
 |
« Reply #9 on: May 22, 2008, 02:37:37 » |
|
if you are exporting for some quake 2 md2's the normals should be equal in each frame.
|
|
|
|
|
Logged
|
|
|
|
Rainer
Regular nerd
 
Posts: 71
|
 |
« Reply #10 on: May 22, 2008, 04:16:54 » |
|
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...
|
|
|
|
|
Logged
|
|
|
|
bobjob
Prolific Timewaster
   
Posts: 335
LWJGL: WOW SO GOOD
|
 |
« Reply #11 on: May 22, 2008, 04:39:32 » |
|
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
|
|
|
|
|
Logged
|
|
|
|
Rainer
Regular nerd
 
Posts: 71
|
 |
« Reply #12 on: May 22, 2008, 04:49:51 » |
|
well, since blender 2.46 changed the uv unwrapping i anyway have to re-learn this :p hope i get it to work somehow.
|
|
|
|
|
Logged
|
|
|
|
|