PDA

View Full Version : how to speed up the drawing of moving 3ds model?



wow
04-12-2004, 07:35 AM
Hi all, it seems that display list, vertex arrays can only be used to speed up the drawing of static model. Is it so? If so, is there any way to speed up the drawing of moving 3ds model such as moving cars?

Thx a lot

CrazyButcher
04-12-2004, 09:38 AM
vertex arrays can have dynamic meshes as well, its just a quicker way of drawing instead of doing those glVertex... commands
just like any array you can change the content, and when you draw the array it will use what is in there.

display lists can be used for mvoing things as well. It just means that "within the list nothing can move"

like if you want to move the car, the car body would be a display list, and one wheel would be a dlist.

when you call a list it will be positioned/ scaled/ rotated like where you are at the moment.

so lets say you have stored your carbody and carwheel display lists already you could make a function like this the numbers are of course just dummys

void drawcar(){
// move up a bit for the body
glTranslated(0,10,0);
glCallList(bodyid);
// place the wheels
glTranslated(-5,-10,5);
glCallList(wheelid);
glTranslated(-5,0,-5);
glCallList(wheelid);
glTranslated(5,0,5);
glCallList(wheelid);
glTranslated(5,0,-5);
glCallList(wheelid);
}

now in your main render function you could do like

...
glLoadIdentity();
glTranslated(x,0,0);
drawcar();
...
x++;

whereas x would be a global variable, your car would then move every frame a bit, this is not ideally since its speed would depend on how often you render the image...

you could just as well throw the whole car into a display list, but with splitting the wheels you could extend your drawcar() function to make the wheels spin.

so display lists can be used for animating things that dont change their topology, ie. if you wanted to crash your car and get deformations, you couldnt do it with display lists.

but vertex arrays you can deform freely