Archived

This topic is now archived and is closed to further replies.

Own Model Format, how to render?

This topic is 5147 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''m making my own model format for this game im working on where the limbs of the characters can be chopped off. I pritty much have how im going to render it. Each member of the body is a geometry class and after the matrix is all setup for it I call its draw method. I havn''t actualy tested this yet but I have a feeling since the verticies are assigned to each member that when one is severed there will be stretched polygons between the severed members, not to mention the holes left if this dosn''t happen. So what im asking is do you think it would be more efficient if I would create a display list for each member, and have each member capped. Or double up the verticies at the joints of the members and render them in the normal GL_TRIANGLES way I was planning? One problem I think I would face with display lists is that eventualy I want the members to accept blood splatters. Since the members geometry are shared by all instances of the same character, I dont think I could change the textures and coordinates per instance. I hope all that made sense and thanks ahead of time for help.

Share this post


Link to post
Share on other sites
All I can say is, sounds like my kind of game!

And I''m gonna go with...it depends on the rest of your design. If the geometry is pretty static, it may be good to go with display lists (or even better, VBOs)


Brian J

Share this post


Link to post
Share on other sites
Yea it should be pritty cool. Um, whats a VBO? and Will a display list ever become slower then not if there are two few verticies drawn in it?

Share this post


Link to post
Share on other sites
A VBO is a vertex buffer object. It''s a good way to store your vertex data in hardware. But this is where I can''t help you anymore, because I''m a D3D man myself . I just know a decent amount about OpenGL and the ARB. I''m sure you will find tons of information on google or on this site. Good luck


Brian J

Share this post


Link to post
Share on other sites
So its a vertex buffer like in D3d. I used to mess with that, could never get my frame rate above 10 or so. That was before my knowledge of the matrix. I would, everyframe, manualy update every verticies new position and resave it in a buffer. I guess thats not the fastest thing in the world.

Share this post


Link to post
Share on other sites
I would do something like this:

1) keep entire mesh in a vertex buffer
2) build a triangle list for each piece, and a capping list for each possible slice position, in system memory
3) build the actual triangle list/buffer by just concatenating triangle lists for pieces that are still connected; cap by concatenating capping lists for things that are severed
4) render the entire mesh using a single call (perhaps two calls, if you use a separate severed texture for the caps)

Note that you only need to re-build the list when the pieces get severed; you don''t need to do it per frame. Note that you can start out with a single mesh instance, and if you chop off an arm, you might spawn a separate "dummy" mesh for the arm piece flying away; the original and arm meshes can still refer to the same vertex buffer, but be rendered using different triangle lists as different calls.

Share this post


Link to post
Share on other sites
I guess i dont know as much about opengl as i thought i did. If i have all my characters mesh in a single triangle list. And render it with one call. How would i apply the transformations of each joint?

Share this post


Link to post
Share on other sites
The way I do characters, and I think this is pretty standard, is to have a hierarchical structure of (invisible) bone objects and animate those.

The character is single mesh, with skin information. Each vertex is driven by one or more bones, and each vertex/bone pair has a weight and offset vector; the offset vector is the vertex's position in the bone's coordinate system. When the driving bones are moved, the offset vectors are transformed by the corresponding driving bones absolute transformation matrices, and the final vertex positions are the weighted average of all the transformed offset vectors for each bone driving that vertex.

A simpler way to do this is to have one bone driving each vertex.

[edit: and just to clarify, to transform the vertices, I obviously don't use gl matrix commands, since I'm rendering the model in a single vertex array. I do the transforms manually using my own matrix class.]

[edited by - benjamin bunny on November 6, 2003 11:26:18 AM]

Share this post


Link to post
Share on other sites
Yea i understand how to render the models as far as a heirarchy and what not. Why is it so obvious not to use the gl matrix transformations, thats what im currently using. Thats why rendering a single mesh wouldn''t work for me.

Share this post


Link to post
Share on other sites
quote:
Original post by honayboyz
Yea i understand how to render the models as far as a heirarchy and what not. Why is it so obvious not to use the gl matrix transformations, thats what im currently using. Thats why rendering a single mesh wouldn't work for me.


You can use gl transformations on non-deformable meshes, but if you're transforming individual vertices (as with the character skin I described), you can't. Even if you use glBegin/glEnd, using transformation functions in the glBegin/glEnd pair is illegal.

If you absolutely need hardware acceleration for skinning then you can always write vertex shader however.

[edited by - benjamin bunny on November 6, 2003 7:48:26 PM]

Share this post


Link to post
Share on other sites
hm
can you modify the content of a VBO with a vertex shader?

otherwise id say you create 2 vertex arrays for rendering the model and precalculate the mesh for the current frame and the next frame
and then simple do some interpolation between the frames and checken when you need to transform the mesh for the nextnextframe *g*


or is there a way you can use 2 vertex arrays simultaneously?

Share this post


Link to post
Share on other sites
I think im on the right track now. With vertex arrays and a matrix class to transform my verticies. Has anyone else tried to this? This seems pritty tricky. If the arm gets cut off at the shoulder I want to keep the bones of the elbow and hand in tact because eventualy I hope to make the arm twitch. I also hope to add a particle system to shoot blood out of the joints.


Share this post


Link to post
Share on other sites
How does this look for splitting up the mesh? I haven't syntax checked it and I just made up the memorycopy function but I know one exists. Seems like I have to loop alot.


This function will be called after loading the model, and everytime a new limb is severed. Then the peice count will increment and a new member will have its severed property true.


int Peices = 1;
cVertex **meshes = 0;
cVertex *mainmesh; //this is hte entire mesh loaded, read only please

cMeshSegment MeshSegments[23]; //each contain start and length of a chunk of the mesh (ex: uppertorso)

cMember Members[15]; //"bones", contains severed and resultant matrix

long *meshsize=0;


CreateMesh()
{
long tempsize = 0;
int i = 0, m = 0;
int copystart = 0, copylength = 0;
//cleanup

if (meshes)
if (peices ==2) //was 1

{
delete[] *meshes; //delete verticies

delete meshes; //delte pointer

delete meshsize;
}
else //was 2+

{
for(i = 0; i < peices-1; i ++) //peices-1 = wut it used to be

delete[] meshes[i]; //delte vertiices arrays


delete[] meshes; //delete array of pointers

delete[] meshsize;
}
//end cleanup

//alocate new

if (peices==1)
{
meshes = new cVertex; //one mesh please

meshsize = new long;
}
else
{
meshes = new cVertex[peices]; //this number of meshes please

}

i=0;
m=0; //start at lower torso

while (i < peices) //this ignores adding the caps for now, just trys to spit up the mesh into differnt meshes

{
tempsize = 0;
while (1)
{
tempsize += meshsegments[m].length;
if (member[m].severed)
{
break;
}
m++;
}
meshsize[i] = tempsize;

meshes[i] = new cVertex[meshsize[i]]; //alocate array

i++; //next peice

}
// array alocated


//copy data

if (peices == 1)
{
copymemory(mainmesh, *meshes, 0, meshsize * sizeof(cVertex); //copy the whole main mesh, assume: (from, to, start, length)

}
else
{
i = 0;
m = 0;
while (i < peices) //this ignores adding the caps for now, just trys to spit up the mesh into differnt meshes

{

copymemory(mainmesh, meshes[i], copystart, meshsize[i]); //copy that hunk of mesh

copystart += meshsize[i]; //where to start from next

i++; //next peice

}
}
//smile cause now meshes is an array of arrays to verticies for your mesh, and meshsize is an array of the lenght of each mesh segment

}




Edit: explain arbitrary array size:

15 members

lower torso
upper torso
head
left upper arm
left lower arm
left hand
right upperarm
right lower arm
right hand
left upper leg
left lower leg
left foot
right upper leg
right lower leg
right foot


23 meshsegments

15 members + severed caps:

torso
neck
shoulder
elbo
hand
hip
knee
foot

[edited by - honayboyz on November 10, 2003 6:26:36 PM]

[edited by - honayboyz on November 10, 2003 6:45:33 PM]

Share this post


Link to post
Share on other sites