Archived

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

Slickfty2

Collisions and optimizations

Recommended Posts

Simple optimization question first. Is it better to scale the model coordinates as they''re being loaded (ie xcoord *= 0.05) than to use glScale*() when rendering each model? And as this applies to collision detection, is it better to do it that way and calculate the bounding box proportions with the scaled coordinates? Thanks

Share this post


Link to post
Share on other sites
Appended question... I''m using the MD2 loader from lesson 7 (Model Mania), and it''s loading "glCommands". Where from this would I even get the coordinates to scale, and calculate the bounding volume from?

Share this post


Link to post
Share on other sites
its faster to do everything when loading rather than each frame. So, yes scale when loading. for collision, calculate with the same data you draw with, or it might not match in size.

Share this post


Link to post
Share on other sites
I''m still not clear how, since the tutorial model loader loads the "glCommands", to get the vertices to scale when loading. Does anyone have an example of how to do that during model loading?

Thanks

Share this post


Link to post
Share on other sites
Is your model loading routine a seperate function?

If not, it should be.

Then once you''ve seperated off this code, you''ll basically read in each piece of data, scaling it as you go, including calculating/scaling any normals you need. Then as I''m assuming you''re doing so now, you will store the newly scaled vertex/normal data in an array for drawing later on (in the main drawing loop).

HTH

Share this post


Link to post
Share on other sites
Ok. I think I see what you''re saying. I''m using NeHe''s Tutorial 7 which has a MD2 class (I''ve modified it to fit my needs, but the structure is essentially the same). The MD2 class has a routine to load the model into an array of glCommands. Then the rendering function uses those glCommands. You would suggest instead of using them to render, maybe build some vertex arrays from then (scaling as I go) in the loading routine and then render with the vertex arrays in the rendering routine? If I''m rendering with vertex arrays, would I have to use a vertex program to do cel-shading?

Share this post


Link to post
Share on other sites